Final Keyword in Java
The final keyword in java is used to make declarations final. Once done you never ever change it. Sometimes programmer does not want that other programmer can use its complicated written methods or classes and extend the features using Inheritance in Java. So final keyword helps to get this job done. Let's explore the final methods, final variables & final classes.
The final class can never be overridden. Yes, you cannot extend the class which is declared as final. The following figure clear your concept.
The final method cannot be overridden by the subclass. Yes, you cannot extend the method also which is declared as final. The following figure will clear your concept .
The final variables cannot be changed once it is initialised. final variable cannot be assigned a new value. The following figure will clear your concept .
Largest collection of up-to-date tutorials to learn programming languages. We are focused on easy learning. Massive collection of interview questions one may need for preparation.