2016/09/21 Java keyword final, 2016 final
1. final class
The final class cannot be inherited and has no subclass. The methods in the final class are final by default.
The final class cannot be inherited. Therefore, the member methods of the final class have no chance to be overwritten. By default, they are all final.
2. final Method
The final method cannot be inherited by the quilt class, but can be inherited.
3. final variable
The final modified member variable is used to represent constants, and the value cannot be changed once given.
When final variables are defined, they can be declared first without initial values. This variable is also called final blank. In any case, the compiler will ensure that the blank final must be initialized before use.
4. final Parameters
When the function parameter is of the final type, you can read and use this parameter, but you cannot change the value of this parameter.
Public class Test {public static void main (String [] args) {new Test (). f1 (2);} public void f1 (final int I) {I ++; // I is of the final type and cannot be changed. system. out. print (I );}}
The final local variable i cannot be assigned. It must be blank and not using a compound assignment