https://grokonez.com/java/java-8/java-8-streams
Java 8 Streams
Java 8 comes with some prominent features like Lambda Expressions, Method References. And Streams are also an important concept that we should comprehend.
This tutorial will help you have a deep view of Java 8 Streams: what they are, ways to create them, how they work with intermediate operations, terminal operation…
This is an example of a Stream:
List numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9);
// get List from Stream Operation
List result = numbers.stream()
.filter(i -> (i % 2) == 0)
.map(i -> "[" + i + "]")
.collect(Collectors.toList());
System.out.println(result);
Run the code above, the console shows:
[[2], [4], [6], [8]]
Now, we have concept of using a Stream is to enable functional-style operations on streams of elements. Those operations are composed into a stream pipeline which consists of:
Source
> Intermediate Operations
> Terminal Operation
More at:
https://grokonez.com/java/java-8/java-8-streams
Java 8 Streams
#java #java8 #stream