Final summary for keywords

1, final keyword can be used for member variables, local variables, methods and classes.
2, final member variables must be initialized when they are declared or initialized in the constructor, otherwise it will report compilation errors.
3, you can not assign a variable final again.
4, local variables must be assigned at the time of declaration.
5, in an anonymous class in all variables must be final variable.
6, final method can not be rewritten.
7, final class can not be inherited.
8, no initialization when the final declaration of variables referred to the blank final variable (blank final variable), they must be initialized in the constructor, or calling this () to initialize. Do not do so, the compiler will complain "final variable (variable name) needs to be initialized."

Guess you like

Origin www.cnblogs.com/xhlwjy/p/11350321.html
Recommended