Final keyword, javafinal keyword
The final keyword is a reserved keyword in Java. Once the reference is declared as the final type, the reference cannot be changed.
I. Modify Variables
The member variables or local variables modified by the final keyword are called constants. It is mainly used in the following two areas:
(1) constants during the compilation period, which can only be basic types and must be initialized at definition.
(2) During running. We hope it can behave differently according to the object, but we do not want it to be changed at the same time. It can be a basic type or a reference type. The content of the basic type is immutable. The reference type is immutable, and the content is variable.
Ii. Modification Method
The final keyword modifier method cannot be overwritten by the quilt class.
3. modifier class
Classes modified by the final keyword cannot be inherited.
Iv. modifier Parameters
The final keyword modifies a parameter, indicating that the parameter cannot be changed and the value of this parameter cannot be changed in the method.
To maintain parameter consistency in an anonymous internal class, if the parameter of the passed method needs to be used in an internal class, it must be declared as final.
Simply put, copy references. In order to avoid changing the reference value, such as being modified by the external class method, internal classes get different values, so final is used to make the reference unchangeable.
Therefore, if you define an anonymous internal class and want it to use an externally defined parameter, the compiler will require that the parameter reference be final.
Reference: http://www.cnblogs.com/chenssy/p/3390871.html