Declare an object inside or outside a loop?

前端 未结 16 840
广开言路
广开言路 2020-12-07 17:15

Is there any performance penalty for the following code snippet?

for (int i=0; i         


        
16条回答
  •  南笙
    南笙 (楼主)
    2020-12-07 17:50

    You can disassemble the code with javap -c and check what the compiler actually emits. On my setup (java 1.5/mac compiled with eclipse), the bytecode for the loop is identical.

提交回复
热议问题