Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualCornstalks

Posted 28 December 2012 - 05:06 PM

Assuming you mean while (true) vs for (;;) vs do { } while (true), no, there's no technical difference.
 
However, I've seem some compilers generate a warning* for while (true) and do { } while (true) but not generate a warning for for (;;), in which case for (;;) may be preferred to avoid a warning.
*For example, see this question.

Edit: I just realized this question was tagged Java and was assuming C or C++ when I was talking about the warning stuff. It's the same in Java as it is in C and C++ in that there's no real technical difference between these infinite looping methods, but the compiler warning issue I talked about isn't relevant in Java.


#2Cornstalks

Posted 28 December 2012 - 04:36 PM

Assuming you mean while (true) vs for (;;) vs do { } while (true), no, there's no technical difference.

 

However, I've seem some compilers generate a warning* for while (true) and do { } while (true) but not generate a warning for for (;;), in which case for (;;) may be preferred to avoid a warning.

*For example, see this question.


#1Cornstalks

Posted 28 December 2012 - 04:35 PM

Assuming you mean while (true) vs for (;;) vs do { } while (true), no, there's no technical difference.

 

I've seem some compilers generate a warning* for while (true) and do { } while (true) but not generate a warning for for (;;), in which case for (;;) may be preferred to avoid a warning.

*For example, see this question.


PARTNERS