-
Final can be used to modify the structure: classes, methods, variables
-
final is used to modify a class: this class cannot be inherited by other classes. For example: String class, System class, StringBuffer class.
-
final is used to decorate the method: this method cannot be overridden. For example: getClass() in the Object class.
Extension: The method modified with the native keyword indicates that the method uses C/C++ code. -
Final is used to modify variables: the "variables" at this time become constants
4.1 final modified attributes, the positions of assignment that can be considered are: display initialization, initialization in code blocks, initialization in the constructor
4.2 final modification of local variables, especially the use of final When modifying a parameter, it indicates that the parameter is a constant, and only this parameter can be used in the method, and its value cannot be changed. -
Static final is used to modify attributes: global constants
Use of final keywords
Guess you like
Origin blog.csdn.net/AmorFati1996/article/details/108718546
Recommended
Ranking