top of page

Stream API Intermediate Operations

Intermediate Operations


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.


The Intermediate Operations can be classified as “stateful” and “stateless” based on their ability to process elements independently.


1. Stateful Intermediate Operations is that require not only the current stream element but also additional state. For example:

sorted() -> Sort elements into natural order

distinct() -> Element goes to next state if it appears the first time

2. Stateless Intermediate Operations need nothing other than the current Stream element to perform its work. For example:

map() -> Maps element to something else

filter() -> Apply predicate and keep or drop element



Single post: Blog_Single_Post_Widget
bottom of page