Posted by Michael Carlson
It's post increment, the assignment happens and then i is incremented.
Its a misconception among ppl that assignment occurs before increment but its wrong.
If u see the precedence order, postfix operator has higher precedence than assignment. So i++ is executed first.
Here is the order of execution.
1. i++ gets evaluated, so i becomes 1 but still the value of the expression i++ is zero.
U can
test it by...
System.out.println(i++); it prints 0. if i is zero initially
Even in method call,
meth(i++, i) means-->>> meth(0, 1) if i is initially zero.
jst remember this. first VM stores the value of i which is zero to some temporary location then increments its value by one. So i becomes one, but the value which is assigned to i is again temporary location value.
Hence i again becomes zero.
Naseem
[ May 31, 2006: Message edited by: Naseem Khan ]