Java 8 Stream – The peek() is not working with count()?
Many examples are using the .count() as the terminal operation for .peek(), for example: Java 8 List<String> l = Arrays.asList("A", "B", "C", "D"); long count = l.stream().peek(System.out::println).count(); System.out.println(count); // 4 Output – It’s working fine. A B C D 4 However, for Java 9 and above, the peek() may print nothing: Java 9 and above …