June 2018
Beginner
722 pages
18h 47m
English
The following two intermediate operations sort the stream elements. Naturally, such an operation cannot be finished until all of the elements are emitted, so it creates a lot of overhead, slows down performance, and has to be used either for the small size streams:
Here is a demo code:
List<String> list = List.of("2", "1", "5", "4", "3");list.stream().sorted().forEach(System.out::print); //prints: 12345list.stream().sorted(Comparator.reverseOrder()) .forEach(System.out::print); ...
Read now
Unlock full access