java for loop pre-increment vs post-increment

Posted by rails_guy on Stack Overflow See other posts from Stack Overflow or by rails_guy
Published on 2010-04-12T16:43:55Z Indexed on 2010/04/12 16:53 UTC
Read the original article Hit count: 415

Filed under:
|
for (int i = 0; i < 3; ++i)
   System.out.print(i + ".."); //prints 0..1..2


for (int i = 0; i < 3; i++)
   System.out.print(i + ".."); //prints 0..1..2

So what is the difference? in what cases can the pre-increment be used wrongly or by mistake which causes a bug...

© Stack Overflow or respective owner

Related posts about java

Related posts about increment