Does using final for variables in Java improve garbage collection?

后端 未结 15 2200
南笙
南笙 2020-11-29 18:01

Today my colleagues and me have a discussion about the usage of the final keyword in Java to improve the garbage collection.

For example, if you write a

15条回答
  •  被撕碎了的回忆
    2020-11-29 18:27

    GC acts on unreachable refs. This has nothing to do with "final", which is merely an assertion of one-time assignment. Is it possible that some VM's GC can make use of "final"? I don't see how or why.

提交回复
热议问题