Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

use of for(;;) ?

 
Prashanth Naidu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,
i dont understand what the use of a for loop in the following fashion:
for(; {....}
please clarify my doubt.. thank you
-P-
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean with empty slots inside the parentheses? That's a "forever" loop. If there's nothing in there, then there'e no exit condition, and so the loop goes forever.
Personally I prefer to write this as "while (true)", but "for (;;)" is OK too.
 
Jeffrey Spaulding
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition to the previous posting.
I use this form ( i also prefer while( true ) { ... } ) when i can
have many different reasons to leave a loop with
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!