The ++i idiom may be a holdover from early C programming days.
As we all know, i++ "returns" the value of i BEFORE the increment, while ++i has the NEW value of i. In pseudo-assembly, i++ might look like this:
Whereas ++i can remove the use of registerB to hold the non-incremented value of i:
In both cases, the expression's value is left in registerA, ready to be assigned to a new variable, passed to a function, etc.
Soon, however, compilers became smart enough to recognize situations where the value of the i++ expression was being ignored, so they didn't bother saving the original value, thus making i++ just as efficient as ++i.
However, some programmers got into the habit of always using ++i and found no reason to stop. You never know, after your current
Java programming job, you might start working with a new language that doesn't have the optimization, and a habit of using "++i" will serve you well.
And lastly, if you're reading code out loud, it's easier to say, "increment i," when you see ++i than when you see i++.
[ October 04, 2005: Message edited by: Ryan McGuire ]