public static void main(String[] args) { for (;;){ System.out.println("for"); } } public static void main(String[] args) { while (true){ System.out.println("while"); } }
说实话,很差区分,那咱们只能从字节码方面看看,java
while(true) 编译后的字节码性能
for(;;) 编译后的字节码code
能够看到,这两个的字节码是一致,全部咱们能够得出结论,这两个死循环的性能是同样的blog