Does use of final keyword in Java improve the performance?

前端 未结 13 1297
粉色の甜心
粉色の甜心 2020-11-22 08:42

In Java we see lots of places where the final keyword can be used but its use is uncommon.

For example:

String str = \"abc\";
System.ou         


        
13条回答
  •  一向
    一向 (楼主)
    2020-11-22 09:12

    Members declared with final will be available throughout the program because unlike nonfinal ones, if these members have not been used in program, still they would not be taken care by Garbage Collector so can cause performance issue due to bad memory management.

提交回复
热议问题