Sorry I think I understand now.
i++ and ++i will both change the value of i to i + 1
i++ will evaluate i and then increment i
++i will increment i and then evaluate i
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Sorry I think I understand now.
i++ and ++i will both change the value of i to i + 1
i++ will evaluate i and then increment i
++i will increment i and then evaluate i
Last edited by Evan407; August 20th, 2014 at 09:26 PM.
Correct. What causes a lot of confusion is when people try
and are surprised when it displays 5 and not 6.int i = 5; i = i++; System.out.println(i);
Improving the world one idiot at a time!
@Evan407: Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.
Please don't edit your posts so that the original question is removed or altered so that the thread no longer makes sense. You could have added your understanding to your original question rather than replacing the original question with your own answer.