why is the enhanced for loop more efficient than the normal for loop

后端 未结 7 1771
一整个雨季
一整个雨季 2020-12-01 00:35

I read that the enhanced for loop is more efficient than the normal for loop here:

http://developer.android.com/guide/practices/performance.html#fo

7条回答
  •  被撕碎了的回忆
    2020-12-01 00:45

    From Effective Java :

    The standard idiom for looping through an array doesn’t necessarily result in redundant checks. Modern JVM implementations optimize them away.

    But Josh Bloch doesn't describe how JVM optimizes them.

提交回复
热议问题