This discussion comes up a lot: http://www.coderanch.com/t/242161/java-programmer-SCJP/certification/Unexpected-output The two things to note are: 1) The behavior of this is undefined in C++. You may see one result in one compiler and another result in another compiler. 2) The postfix operator returns a result and then increments. So when you do i = i++, if i = 0 then you are getting: a) return 0 b) increment i to 1 c) assign the returned value of 0 to i Operator precedence says that postfix occurs before assignment.