How can I do the following nested loop using java stream?
for (int x = 0; x < 5; x++) {
for (int y = 0; y < 5; y++) {
System.out.println(x + ", " + y);
}
}
I can easily do one loop with IntStream.range(0, 5). Is this possible with streams?
EDIT: well I guess I can do this, but can it be done with flatMap?
IntStream.range(0, 5)
.forEach(x -> IntStream.range(x, 5).forEach(y -> System.out.println(x + ", " + y)));