the role of the final keyword in Java :
A.acting on a class : It is not allowed to extend the class, that is, you cannot define subclasses with that class.
b. Acting on methods : Subclasses cannot override this method, but can be inherited.
in early Java, programmers used final to avoid the overhead of dynamic binding. Now this function is mainly implemented by compilers.
C.action on domain : The value of the field cannot be changed after the object is constructed.
D. function parameter : can read, but cannot change the parameter.
Note:all methods of the final class automatically become final, excluding fields.
The primary purpose of declaring a method or class as final is to ensure that they do not change semantics in subclasses.
The string Class is a final class and does not allow a subclass of string to be defined. If there is a reference to a string, it must refer to a string object, and it cannot be an object of another class.
The final keyword in C + + is new in C + +11 and acts as:
A.acting on a class: Prevents a class from becoming a base class, that is, it is not allowed to extend the class.
b. Acting on virtual methods : The organization derived class overrides this virtual method.
The role and difference of the final keyword in Java and C + +