Do javac or Hotspot automatically add 'final' as an optimisation of invariant variables?

后端 未结 4 2016
北荒
北荒 2021-01-13 11:40

The consensus seems to be that there is a performance benefit to marking member variables as final because they never need reloading from main memory. My question is, do jav

4条回答
  •  春和景丽
    2021-01-13 12:17

    AFAIK, they do not, and thus, you suffer minor penalty. This, however, can be done automatically with IDE tools like Eclipse "Cleanup" feauture.

提交回复
热议问题