posted 20 years ago
This is all about evaluation of operands. Let me explain exactly what is happening and you can draw your own conclusions.
Here's our line of code:
In order to evaluate this expression, we must first evaluate operands, from left to right. The first operand we evaluate is j++. As you already know, this operand evaluates to 0 but, as a side-effect, j is incremented to 1. We now have this:
Now, we evaluate the next operand, which is just j. At this point, j is 1 so our expression evaluates to this:
Obviously, that expression assigns the value of 1 to j.