What is the difference between a standard while(true) loop and for(;;)?
Is there any, or will both be mapped to the same bytecode after com
It's up to you which one to use. Cause they are equals to compiler.
create file:
// first test
public class Test {
public static void main(String[] args) {
while (true) {
System.out.println("Hi");
}
}
}
compile:
javac -g:none Test.java
rename Test.class Test1.class
create file:
// second test
public class Test {
public static void main(String[] args) {
for (;;) {
System.out.println("Hi");
}
}
}
compile:
javac -g:none Test.java
mv Test.class Test2.class
compare:
diff -s Test1.class Test2.class
Files Test1.class and Test2.class are identical