+1 vote
in JAVA by
What is the difference between intermediate and terminal operations on Stream?

1 Answer

0 votes
by

The intermediate Stream operation returns another Stream, which means you can further call other methods of Stream class to compose a pipeline.

For example after calling map() or flatMap() you can still call filter() method on Stream.

On the other hand, the terminal operation produces a result other than Streams like a value or a Collection.

Once a terminal method like forEach() or collect() is called, you cannot call any other method of Stream or reuse the Stream.

Related questions

0 votes
asked Apr 15, 2021 in JAVA by SakshiSharma
+1 vote
asked Apr 15, 2021 in JAVA by SakshiSharma
...