Because the value of y
is calculated in for
statement and the value of x
is calculated in its own line, but in the System.out.println
they are only referenced.
If you decremented inside System.out.println
, you would get different result.
System.out.println(y--);
System.out.println(--y);