Why is the finalize() method in java.lang.Object “protected”?

前端 未结 9 1303
旧时难觅i
旧时难觅i 2020-11-29 04:28

Out of curiosity,

Why is the finalize() method\'s access modifier is made as protected. Why cant it be public? Can someone exp

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

    I think the reason why finalize is protected would be that maybe it's overridden by some classes in the JDK, and those overridden methods are called by JVM.

提交回复
热议问题