why is final keyword used in java?
It is a modifier that indicates that a class cannot be extended, a variable cannot be changed, and a method cannot be overridden.
The final keyword is used in java due to following reasons:
* A java variable that is declared with the keyword final can be assigned only once. They cannot be modified. * A variable that is declared as final and not initialized is called a blank final variable. A blank final variable forces the constructors to initialize it. * Java classes declared as final cannot be extended. It cannot be inherited by any other class. * Methods declared as final cannot be overridden in the sub classes. * final parameters - values of the parameters cannot be changed after initialization. * Java local classes can only reference local variables and parameters that are declared as final. * A visible advantage of declaring a java variable as static final is, the compiled java class results in faster performance.
keyword final can be assigned only once. They cannot be modified.