Java 8 Streams

Java 8 Streams is an API created in Java 8, being used to be able to help run methodsthrough simple pipelines to get the result. This is similar to lambda in Python3.

The above image shows how the source is first run through methods in a pipeline, then finally going through the collect keyword to end the process.

In Java 8 Streams, there are two types of operations.

The first type of operations is intermediate operations, which are the methods run in the pipeline to interact with the original source.

The second type of operation is the terminal operation, which ends the pipeline and helps return the final result.

Below is an example on how this process works.

Examples of Intermediate Operations: Map, Filter, Sorting

Examples of Terminal Operations: Collect, forEach, Reduce

I hope this post helped and try to use Java 8 Streams, as they are very helpful for navigating your way through java!

Written on August 8, 2021