How do you define a stream, and how does it different from a collection?
A stream is an iterator whose primary role is to accept a set of actions to apply on each of the elements it contains.
Some of the points of difference are -
The stream represents a sequence of objects from a source like a collection, that supports aggregate operations.
Streams have been designed to make collection processing simple and concise. In contrast the collections, the concept of iteration is implemented inside the stream, so that we can use methods like map and flatMap for performing a declarative processing.
The Stream API is fluent and allows pipelining, and yet another important distinction from collections is that streams are inherently lazily loaded and processed.