Final Class A {}, so that the defined Class A is the final class, the final class cannot be inherited, that is, the code cannot be written, class B extends a {}.
final void B () {}, the method defined is the final method, and the final method cannot be overridden in a subclass, that is, if a subclass inherits the class of the final method, then the method of void B () {} can no longer appear in this subclass.
-----------------------------------------------------------------------------
The final class may not contain the final method, and the class containing the final method can be either the final class or the non-final class.
The final class has a final decoration and can not derive subclasses.
-----------------------------------------------------------------------------
A class that is final decorated cannot be inherited, so it cannot be used as a parent class for other classes, and is typically represented by the string class. The string class only lets you use it directly.
-----------------------------------------------------------------------------
Final can modify classes, methods, and variables.
When modifying a class: it means that the decorated class is the final class, and any class can no longer inherit it.
When modifying a function: It means that the method is the final method in the class, and the method that inherits the subclass of the class cannot rewrite it.
When modifying a variable: it means that the modified variable is a constant or an end-state variable, and once initialized it is no longer possible to change the value of the variable.
What is the final class and the final method in Java? What are their roles?