Stream Vs Collection

The collection API was introduced in JDK 1.2, and received regular updates with different versions of Java. With the introduction of JDK 1.8 one new API was introduced known as Stream API.
Collection and stream, while sharing some similarities, both are conceptually different and have different goals. Collection and Stream can be easily distinguished by the following points: 
  • The collection is used to store data then the stream is used to perform an operation on that data.
  • The collection is primarily concerned with efficient management and access to their elements while stream does not provide a means to directly access or manipulate their elements.
  • Stream provides more operations behind the scenes than collection.
  • Constructor in the collection is eagerly constructed,  in stream it is lazily constructed.
Streams differ from collections in various ways,
  • No storage
    A stream is not a data structure that stores elements; instead it conveys an operation on those elements.
  • Functional nature
    An operation on stream elements produces a result, but does not modify the source.
  • Laziness
    Some stream operations like filter, limit, map, etc can be implemented lazily. Stream operations are divided into intermediate and terminating operations in which intermediate operations are always lazy.
  • Unbounded
    Operations like limit(n), findFirst() or findLast() can allow computations on infinite streams to complete in finite time. Streams are independent or unbound with size.
  • Consumable
    The elements of a stream are only visited once in the life of a stream.


This blog should  be helpful in understanding some differences between Stream and Collection API, for a detailed description of stream API, refer to the article here.