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 6358423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:22:17+00:00 2026-05-24T23:22:17+00:00

Looking through some old company code, I came across a for loop that looks

  • 0

Looking through some old company code, I came across a for loop that looks like this:

for (;;) {
    //Some stuff
}

I tried Google but couldn’t find any answers. Did I fall asleep in a programming class or is this an unusual loop?

  • 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-24T23:22:20+00:00Added an answer on May 24, 2026 at 11:22 pm

    A for loop in java has the following structure –

    for (initialization statement; condition check; update)
        loop body;
    

    As you can see, there are four statements here –

    1. Initialization statement: This statement is executed only once, when the loop is entered for the first time. This is an optional statement, meaning you can choose keep this field blank. It is generally used for some initialization purpose.
    2. Conditional check: This statement is probably the most important one. It checks to verify whether or not certain expression evaluates to true. If it is, then the loop execution continues. You can choose to keep this field empty, which will be evaluated to true.
    3. Update: This statement list is executed from left to right, typically used to increment/decrement some variable.
    4. loop body: The body of the loop, which will be executed again and again based on the conditional check’s truth value.

    Basically this is how the execution follows – first, when the loop is entered for the first time, the initialization statement is executed once. Then the conditional check is executed to see if it evaluated to true. If it is, then the the loop body is executed, otherwise the loop execution is finished. After that, the Update statement(s) is(are) executed. Next, the conditional check is executed again, and if it evaluates to true, then again the loop body is executed, then update statement is executed, then again the conditional check….you get the picture.

    Now about your for( ; ; ) syntax. It has no initialization statement, so nothing will be executed. Its conditional check statement is also empty, which means it evaluates to true after that the loop body is executed. Next, since the update statement is empty, nothing is executed. Then the conditional check is performed again which will again evaluates to true and then this whole process will again repeat.

    So you see, this is basically an infinite loop which has no initialization statement, whose conditional check will always evaluates to true, and which has no update statement. This is equivalent to –

    while(true)
    {
        .....
    }
    

    which is another popular loop construct in java.

    When you use an infinite loop like this, it’s important pay attention to the breaking condition as in most cases you can’t let a loop to run indefinitely. To break out of these kinds of loops, you can use the break statement. The structure is as follows –

    if(some_condition_is_true)
        break;        // This will cause execution to break out of its nearest loop
    

    or

    if(some_condition_is_false)
        break;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking through some code I came across the following code trTuDocPackTypdBd.update(TrTuDocPackTypeDto.class.cast(packDto)); and I'd like
I was looking through some code for work, and came across this line: eval(\$element
I was looking through Mozilla's JS in JS code and came across the snarf
I have an application that is looking through some files for old data. In
I'm looking through some old code and realize there are a ton of helper
I was looking through some code the other day and I saw something like
I was looking through some Rails code and noticed that one of the classes
I've been looking through some code from a decompiled APK file and ran across
I was looking through some code and i saw this: <xsl:variable name=newlist select=concat(normalize-space($list), '
I have some old C# plugin code that was implemented strictly with Reflection. In

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.