The final reason for the method declaration in java

Original link: https: //blog.csdn.net/qq_qun_247286682/article/details/6848629

First: the method is "locked" to prevent any inheriting class change its original meaning. When designing the program. If you want a method of behavior remains unchanged during inheritance and can not be overwritten or rewritten, you can take this approach.

Second: After taking into account the efficiency of program execution, a method is set to final, the compiler can put all of that method calls are placed "embedded" in the call.

Guess you like

Origin www.cnblogs.com/nikecoco/p/11870378.html