Java streams allow you to process a sequence of elements in a sequential or parallel way. You can create a stream from different data sources, as a Collection, a File or an Array and apply to its elements a sequence of operations normally defined with lambda expressions. Those operations can be divided into two different classes:
- Intermediate operations: These operations return other Stream as a result and allow you to filter, transform, or sort the elements of the stream
- Terminal operations: These operations return a result after processing the elements of the stream
A stream has a source, zero or more intermediate operations, and a terminal operation. The two most important terminal operations are: ...