Java for (;;) loop

I looked at the source of the AtomicBoolean class and found an interesting for loop declaration as follows:

 for (;;) { //Something } 

What does this cycle do?

+4
source share
5 answers

This is an endless cycle. The same can be done with:

 while (true) { //Loops forever. } 

Take a look at the docs .

+11
source

This is short for infinite loop. It will continue until the break statement completes the loop.

+3
source

What does this cycle do?

It ends endlessly. Like it:

 while (true) { } 
+1
source

This is an infinite loop that will not stop execution if it does not have a break statement. This is the same as while(true) .

+1
source
 for (;;) { //Something } 

This is an endless cycle.

0
source

All Articles