A Stream is a sequence of elements supporting sequential and parallel aggregate operations. A stream is to perform operations on collection of elements, which might be an array, a collection, a generator function, an I/O channel, etc. Streams provide a declarative approach to Collections.
To perform a computation, stream operations are composed into a stream pipeline. A stream pipeline consists of a source, intermediate operations and terminal operations.
1. Source – which might be an array, a collection, a generator function, an I/O channel, etc
2. Intermediate operations– which transform a stream into another stream.
3. Terminal operation– which produces a result or side-effect.
1. Streams are Functional in nature. They work perfectly with lambdas.
2. No storage – Streams don’t store any elements.
3. Consumable- The elements of a stream are only visited once during the life of a stream. They are not reusable.
4. Streams are immutable.
5. Streams are sequential or parallelized.
6. Laziness-seeking – Intermediate operations are always lazy.