Java for Loop evaluation

前端 未结 9 2298
孤独总比滥情好
孤独总比滥情好 2020-12-03 21:45

I want to know if the condition evaluation is executed in for and while loops in Java every time the loop cycle finishes.

Example:

9条回答
  •  無奈伤痛
    2020-12-03 22:07

    If the conditional expression is a loop invariant and you are running in JIT mode, loop optimizations such as Loop-invariant code motion can be done.

    But when run in the interpreted mode, I guess there is not much optimization to do.

提交回复
热议问题