What is the best way to transform a while loop like the one below to the functional stream if you don't know the exact number of iterations?
int i = 10;
while (i > 1) {
System.out.println(i);
i--;
}
I came up with something like this, but I want to remove the limit
and stop iteration with something like a predicate condition
Stream.iterate(10, n -> n - 1).filter(n -> n > 1).limit(9).forEach(System.out::println);