Junior — Senior
Investigation of Stream.peek() behavior with lazy execution in Java
livecode
Task condition
Demonstrate how lazy evaluation works and in what order elements are processed when using the Stream API in Java. What will be printed to the console and why?
void m2(){
Stream<Integer> src = Stream.of(1, 3, 2);
src.peek(System.out::println)
.peek(System.out::println)
.count();
}