The code
int i = 0;
i = i++;
System.out.println(i);
produces the output "0" instead of "1".
"i = i++" roughly translates to
int oldValue = i;
i = i + 1;
i = oldValue;
Subscribe to:
Post Comments (Atom)
Blog on Java and Oracle Technologies
2 comments:
I think you will like the explanation that I have given here.
http://skeletoncoder.blogspot.com/2006/09/java-tutorials-i-i.html
This shows the exact Byte Codes, and illustrates step by step at the JVM level.
Java Tutorials: i = i++
Post a Comment