Question about post-increment operator
问题 Why does the following code int i = 1; System.out.print(i += i++); System.out.print(i); output 2 two times instead of 3 for the 2nd print? Could somebody please shed some light on it? Thanks. 回答1: If you realise that a++ works as follows (pseudocode): func ++(ref a) { int b=a; a=a+1; return b; } then it all makes sense. 回答2: It may seems like i should be 3 in the end. However, if you look into the statement more closely i += (i++) is equal to i = ( i + (i++) ) which is, in this case, 1+1. The