Java Stream terminal operations

 275 total views,  2 views today

Welcome to Java 8 series. In this post, you will learn about Java Stream terminal operations.

Java 8 streams are classified into two operations. Intermediate operation and Terminal Operation. Both are combined to form a Stream pipeline.

Terminal operation

A terminal operation produces the final output. Stream pipeline will end with a single terminal operation such as foreach, count, collect, sum.

Once the terminal operation is applied to the stream, we cannot reuse the stream again. We have to create a new stream and create a new stream pipeline again from the source. So, the stream cannot be reused when a terminal operation is applied or invoked.

To put in a simpler way, Stream is considered consumed after a terminal operation is executed.

Every Terminal operation will end the stream and produces a result.

Below are the list of Terminal operations

Conclusion

In this post, we learned about Java Stream terminal operations.

Reference : Official documentation

Please leave a comment and give us a thumbs up!

 

Tags :

About the Author

Rajasekar

Hey There, My name is Rajasekar and I am the author of this site. I hope you are liking my tutorials and references. Programming and learning new technologies are my passion. The ultimate idea of this site is to share my knowledge(I am still a learner :)) and help you out!. Please spread your words about us (staticreference.com) and give a thumbs up :) Feel free to contact me for any queries!.