top of page

Stream Operations (Source, Intermediate and Terminal)

Stream Operations


Stream is a sequence of elements and it supports the different kind of operations to the action of logical or mathematical calculation upon those elements.


It consists of a Source followed by zero or more Intermediate Operations such as “Stream.filter” or “Stream.map” and a Terminal Operation such as “Stream.forEach” or “Stream.reduce” as the following:


1. Source

2. Intermediate Operation

3. Terminal Operation


Source is an entity that stores elements such as array, list etc.


Intermediate Operation returns a new stream so we can connect multiple Intermediate Operations without using semicolons. But these operations do not actually perform until the terminal operation is executed.


Terminal Operation is either void or return a non-stream result.


Let’s see the example.

At the above example, “Arrays.asList” is a source of a Stream, “filter”, “map” and “sorted” are Intermediate operations and “forEach” is a Terminal operation.




Single post: Blog_Single_Post_Widget
bottom of page