- Do not replicate this method to subclasses. You already know that this method provides functionality that satisfies your requirements, does not need to be extended, and does not allow any class that inherits from this class to overwrite this method, but inheritance can still inherit this method, which means that you can use the
- Inline extension. Allows the compiler to convert all calls to this method into an inline call mechanism, which allows you to insert the method body directly into the call when the final method is called, instead of making routine method calls, such as saving breakpoints, pressing stacks, and so on, which may improve your program efficiency. However, when your method body is very large, or you call this method in many places, then your calling body code will quickly expand, it may affect efficiency, so you should be careful to use final method definition
In Factory mode, methods other than factory methods (which require quilts to be expanded and replicated to achieve Factory mode) can be declared as final if they do not want to be modified by the extended subclass of the class.
The role of the final method in the Java class