public static void main(String[] args) {
for (;;){
System.out.println("for");
}
}
public static void main(String[] args) {
while (true){
System.out.println("while");
}
}</code></pre>
说实话,不好区分,那我们只能从字节码方面看看,
while(true) 编译后的字节码

for(;;) 编译后的字节码

可以看到,这两个的字节码是一致,所有我们可以得出结论,这两个死循环的性能是一样的
本文由【暗中观察】发布于开源中国,原文链接:https://my.oschina.net/u/3574106/blog/3136659