Possible Duplicate:
pre Decrement vs. post Decrement
What is the difference between ++i and i++?
I’ve just realized that
int i=0;
System.out.println(i++);
prints 0 instead of 1.
I thought that i was incremented and THEN printed. It seems that the contrary happens.
Why?
These are the pre- and post-increment operators. This behavior is exactly correct.
i++returns the original value.++ireturns the new value.