I'm trying to understand post incrementation at the hand of these 3 examples. But I have difficulties trying to understand the last one.
1.
int x = 0;
x++;
System.out.println(x); //prints out 1
2.
int x = 0;
x = x++;
System.out.println(x); //prints out 0.
x in itself contains 1, but not the left side reference variable pointing to x seeing it's post-incrementation. So the original value is returned.
3.
int x = 0;
do {
x++;
} while (x <= 9);
System.out.println(x); // prints out 10
But according to my reasoning based on the first 2 examples it should print out 9. x
in itself first contains 1, then 2, 3, 4, 5, 6, 7, 8, 9. Could someone please explain the output for the last example?