S'il vous plaît, considérez ce code:
System.out.println("#1");
Stream.of(0, 1, 2, 3)
.peek(e -> System.out.println(e))
.sorted()
.findFirst();
System.out.println("\n#2");
IntStream.range(0, 4)
.peek(e -> System.out.println(e))
.sorted()
.findFirst();
La sortie sera :
#1
0
1
2
3
#2
0
Quelqu'un pourrait-il expliquer pourquoi la sortie de deux flux est différente?