Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

for(;;)

  Asked By: Sam    Date: Jun 24    Category: Java    Views: 390
  

anyone know what for(;;) is?

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Julia Hughes     Answered On: Jun 24


infinte loop......................

 
Answer #2    Answered By: Scarlett Hughes     Answered On: Jun 24

I see a for  loop like this:

for (init_statement; bound_checking; step_statement) {}

So, normally you would do this:

for (int i = 0; i < 10; i++)

But, if i is already defined, then you don't have to put it in the for loop:

int i = 3;
for ( ; i< 10; i++)

And let's say your loop ends only on specific conditions:

int i = 3;
for ( ; ; i++) {
...
if (condition1 && condition2)
break;
}

Now let's say your step is defined somewhere in the loop:

int i = 3;
for ( ; ; ) {
...
if (condition1 && condition2)
break;
i += someNumber;
}

Once you get to this point, for (;;) is the same as do .. while(true), which is
the same as while(true).

 
Answer #3    Answered By: Marina Smith     Answered On: Jun 24

Quick answer to your question - it is an infinite loop (no inital condition, no
conditional check, no increment!)...

 
Didn't find what you were looking for? Find more on for(;;) Or get search suggestion and latest updates.

Related Topics:



Tagged:  

 
 
 

Related Post