1. Final keyword
The final keyword in Java corresponds to the const keyword in c/C + +.
In Java, the final keyword can be used to describe a class, method, member variable:
. The final class cannot be inherited, there are no subclasses, and the methods in the final class are final by default.
. The final method cannot be overridden by a method of a class, but can be inherited.
. The final member variable represents a constant, which can only be assigned once, and the value will no longer change after the value is assigned.
. Final cannot be used to modify a construction method.
Note: The private member method of the parent class is not overridden by the class method, so the private type method defaults to the final type.
。
2. Static keyword
the static keyword in Java is similar to the static keyword in c/a + +.
In Java, the final keyword can be used to describe methods, member variables:
member variables and member methods that are modified by static are independent of any object of the class. That is, it does not depend on class-specific instances and is shared by all instances of the class.
The access syntax is:
Class name. static method Name (parameter list ...)
Class name. Static variable name
Keywords in Java