r/javahelp • u/Encryp73r • Aug 09 '22
what does for(;;) mean?
Just like the title asks, what does for(;;) mean? A double semicolon in a for loop, I found it in some code I'm trying to understand and Google can't seem to answer my question. Thanks!
17
Upvotes
25
u/NautiHooker Software Engineer Aug 09 '22
Equivalent to
while (true)You omit the iteration variable, its incrementation and the exit condition, which means it becomes an endless loop that needs to be ended with a break/return statement somewhere.
If I am not mistaken this way of writing such loops comes from older C like languages that didnt have the option for while(true).