Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6924157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:37:38+00:00 2026-05-27T10:37:38+00:00

Is there a way to pause a for loop in java? So is there

  • 0

Is there a way to pause a for loop in java? So is there a way to only go forward one iteration when prompted? I read this http://answers.yahoo.com/question/index?qid=20100212201605AAazS73 and the solution seems like it could have some problems mostly because I don’t fully understand the order the for loop checks its header. The only method I could think of that could accomplish something similar is the following

    do {
        if (FLAG) {
            //Do procedure
            i++;
            FLAG = false;
        }
    } while ( i < 6);

When the flag is true the procedure is done and the counter moves forward one. I don’t like this, though, because it will keep looping as long as the counter is below 6, if I am not mistaken. Any ideas?

-Sorry for the lack of clarity. The FLAG in my case would be a static boolean that could be called from another class. The procedure I allude to is dependent on i.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:37:39+00:00Added an answer on May 27, 2026 at 10:37 am

    When iterating through a for loop, for example, the one below, it does the following

    for (int i = 0; i < 6; i++) {
        // Do stuff
    }
    
    1. It declares the variable i and assigns a value of 0.
    2. It checks the conditional i < 6. If true, then proceed to step 3. Otherwise go to step 6.
    3. Goes through the body of the loop.
    4. Increment the variable i due to the i++ in the for loop header.
    5. Go to step 2.
    6. The loop ends.

    As for your objective, I’m not sure what your objective is. Are you looking to pause using a blocking method call? If so, then something like this would work:

    for (int i = 0; i < 6; i++) {
        System.in.readLine();
    }
    

    Alternatively, you could use some sort of flag that polls to check whether the loop should proceed, such as:

    for (int i = 0; i < 6; i++) {
        while (paused) {
            // An infinite loop that keeps on going until the pause flag is set to false
        }
    }
    

    Hope this helped.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible duplicate question: Is there a way to indefinitely pause a thread? In my
Is there a easy way to do this? Or do I have to parse
Is there any way to use a loop (for, while, do-while) to loop through
Is there a way to pause the main python thread of an application perminantly?
Is there any way to parse a string in the format HH:MM into a
Is there a way to parse a website's source on the iPhone to get
Is there an easy way to parse the user's HTTP_ACCEPT_LANGUAGE and set the locale
Is there a direct way to parse an iCalendar date to .net using c#?
I've been wondering if there's a way to parse XML in Objective C as
Is there a way to tell ifort or gfortran to just try to parse

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.