Java increment and assignment operator
I am confused about the post ++ and pre ++ operator , for example in the following code int x = 10; x = x++; sysout(x); will print 10 ? It prints 10,but I expected it should print 11 but when I do x = ++x; instead of x = x++; it will print eleven as I expected , so why does x = x++; doesn't change the the value of x ? No, the printout of 10 is correct. The key to understanding the reason behind the result is the difference between pre-increment ++x and post-increment x++ compound assignments. When you use pre-increment, the value of the expression is taken after performing the increment. When