This question is definitely not a duplicate because I do not refer to general post/precrement evaluation but specifically to the use of increment in lambda expressions, which is provably different. Everyone is free to confirm that the code will return zeros only where you would normally expect the variable's value to increase. No answer has been posted to that.
I am well aware of the varying evaluation and incrementation moments of both post- and prefix incrementation. Still, I fail to understand why this returns zeros only:
Stream.iterate(0, e -> e++)
.limit(10)
.forEach(System.out::println);
When checking this, I see e being initialized as 0 during the first iteration and then incremented. So the second iteration should yield e = 1, but apparently it doesn't. What am I missing?
Also, if I reverse the increment, it works as supposed, listing all numbers from 0 to 9:
Stream.iterate(0, e -> ++e)
.limit(10)
.forEach(System.out::println);