Question related to Postfix and Prefix
publicstaticvoid main(String[] args)
{
int x = 0, y = 1, z = 2;
x = x++;
y = --y;
z = ++x + 4;
System.out.println("x =" + x);
System.out.println("y =" + y);
System.out.println("z =" + z);
}
Run the code out and you will find out that the final result is x = 1, y = 0, and z = 5. Expected output should be x = 2, y = 0, z = 6.
My question is
Why when the statement x = x++; executed, the value of x remain as 0?
x++ is postfix but it seem that it was never evaluated based on debugger.
x only become 1 when the statement z = ++x + 4;
The prefix work like normal but postfix is a bit unexpected.
Need an expert to explain this to me.
Thanks.

