The final modifier keyword makes that the programmer cannot change the value anymore. The actual meaning depends on whether it is applied to a class, a variable, or a method.
- final Classes- A final class cannot have sub-classes.
- final Variables- A final variable cannot be changed once it is initialized.
- final Methods- A final method cannot be overridden by sub-classes.
2.What are the uses of final method?
There are two reasons for marking a method as final:
- Disallowing sub-classes to change the meaning of the method.
- Increasing efficiency by allowing the compiler to turn calls to the method into inline Java code.
EmoticonEmoticon