[ACCEPTED]-What do two semicolons mean in Java for loop?-for-loop

Accepted answer
Score: 57

It is equivalent to while(true).

A for-loop has three 2 elements:

  • initializer
  • condition (or termination expression)
  • increment expression

for(;;) is not setting any of them, making 1 it an endless loop.

Reference: The for statement

Score: 9

It's the same thing as

while(true) {
    //do something

...just a little bit 2 less clear.
Notice that the loop will exit 1 if compareAndSet(current, next) will evaluate as true.

Score: 3

It's just another variation of an infinite 1 loop, just as while(true){} is.

Score: 2

That is a for ever loop. it is just a loop 1 with no defined conditions to break out.

Score: 2

It's an infinite loop, like while(true).


More Related questions