【final】

Because there is a phenomenon inherited methods: Method rewrite. Therefore, the function of the parent class will subclasses to overwrite, sometimes, we do not want subclasses to override the function of the parent class, only let him use. At this time, for this situation, java provides a fina l keyword.
 
final keyword
final: The final meaning. Common is that it can be modified classes, methods, variables. Features:
final: class can be modified, the modified final class can not be inherited by subclasses.
final: methods may be modified, final modification of the parent class is not a method subclasses override (override, cover)
final: it can be modified variable that can not be reassigned. In fact, because of this constant is constant.
final modification of the problem of local variables:
Local variables are basic types: the type of value can not be changed substantially.
Local variables are the type of reference: the type of reference address value can not be changed, but the value of the object heap memory can be changed.
final modified variable initialization timing:
A: the final modified variables can only be assigned once.
B: (non-static constant) is completed before the constructor

Guess you like

Origin www.cnblogs.com/zuixinxian/p/11276384.html