This is a complicated question. The same code will result in different values with different languages (e.g. c/c++).
In
java, basically there is a three step process that takes place when there is a postfix operator used in an assignment statement.
step 1. The original value is saved.
step 2. The postfix operation takes place.
step 3. the original value is assigned.
This is not what the programmer is expecting. Most programmers would expect steps 2 and 3 to be reversed.
Let's take a look at this example:
step 1: store the original value of x (TEMP = 0)
step 2: increment x (x = x + 1)
step 3: assign the original value to y (Y = TEMP)
now, let's look at your example:
step 1: store the original value of i (TEMP = 0)
step 2: increment i ( i = i + 1 )
step 3: store the original value to i (i = TEMP)
It is correct per the JAVA language specs, however it is not intuitive and I for one would like to see it behave in a manner more closly to that of C++.