It combines with the same byte code, and this is a matter of taste, which you prefer.
I read a lot of source code from the distributed JDK Oracle, and I can’t easily recall that I saw the while(true) statement in my code, but I saw many for(;;) statements in my code, I personally, I prefer for(;;) , and my reasoning is a bit like this:
The while loop should contain a boolean expression, not a boolean constant. while(true) bit like if(true) , both of which, I think, have become legal only for the added comfort of the masses. An empty while() does not compile. Adding true there is a bit like a hack.
for(;;) , on the other hand, is a "real loop", albeit empty. In addition, it saves you a couple of keystrokes! =) (not so important)
Therefore, and I know that it sounds crazy, but although (the truth) is better read in English, I think that for (;;) it is better to express your intentions and is more akin to the Java programming language. In any case, perpetual cycles should be avoided. When I read (;;), I feel safe knowing that the developer is slowing down the execution path somewhere. When I read (true), I just can't be sure. But hey maybe just me! We can all choose our own taste.
Martin Andersson May 5 '14 at 11:31 2014-05-05 11:31
source share