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 6 of 6

Thread: At what point in a for loop does incrementation take place?

  1. #1
    Junior Member
    Join Date
    Dec 2021
    Posts
    26
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Default At what point in a for loop does incrementation take place?

    Is it at the closing curly bracket, or is it when it gets back to the start of the loop for another repetition?

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: At what point in a for loop does incrementation take place?

    How can you tell when the loop is at the bottom or has returned to the top of the loop? I do not see any way to make use of that difference.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2021
    Posts
    26
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Default Re: At what point in a for loop does incrementation take place?

    I was trying to understand the effect that the continue; keyword has.

    I think it actually increments when it reaches the closing of the loop though, because when I use continue to jump from an inner loop, to the end of an outer loop, the inner loop doesn't get incremented when the program gets to the beginning of that loop again, but the outer loop does get incremented.

    So also tells me another thing I was wondering: does continue jump to the start of the loop or the end of the loop.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: At what point in a for loop does incrementation take place?

    To see what the code does where, you need to read the byte code that is generated by the compiler.
    If you don't understand my answer, don't ignore it, ask a question.

  5. The Following User Says Thank You to Norm For This Useful Post:

    FightingIrishman (December 31st, 2021)

  6. #5
    Junior Member
    Join Date
    Dec 2021
    Posts
    26
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Default Re: At what point in a for loop does incrementation take place?

    That might be a bit beyond my expertise right now, but thanks for the info.

  7. #6
    Junior Member
    Join Date
    Jan 2022
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: At what point in a for loop does incrementation take place?

    Hey,

    The increment expression is invoked after each iteration of the loop.

Similar Threads

  1. Trying to restart a loop at a certain point
    By cod in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 9th, 2014, 05:53 AM
  2. A Pixel Out Of Place
    By tyeeeee1 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: December 4th, 2012, 07:06 PM
  3. One Decimal Place
    By Akirien in forum Object Oriented Programming
    Replies: 5
    Last Post: August 22nd, 2012, 12:11 AM
  4. java Loop program to place distinct value in a row, column and diagonal
    By javanovoice in forum Loops & Control Statements
    Replies: 3
    Last Post: September 8th, 2011, 08:08 PM
  5. Where to place my own library?
    By hexwind in forum Java Theory & Questions
    Replies: 3
    Last Post: June 22nd, 2011, 06:25 AM