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.

Results 1 to 3 of 3

Thread: Question about (10)++%5 == 0

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Question about (10)++%5 == 0

    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.


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Question about (10)++%5 == 0

    Correct. What causes a lot of confusion is when people try
    int i = 5;
    i = i++;
    System.out.println(i);
    and are surprised when it displays 5 and not 6.
    Improving the world one idiot at a time!

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Question about (10)++%5 == 0

    @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.

Similar Threads

  1. Replies: 1
    Last Post: November 4th, 2013, 05:38 AM