The final keyword in java is used to restrict the user. final keyword can be used along with variables, methods and classes.
1)final variable
final variables are nothing but constants. We cannot change the value of a final variable once it is initialized.
public class Adhar
{
final int uid=99;
void myMethod()
{
uid=101;
}
public static void main(String args[])
{
Adhar obj=new Adhar ();
obj.myMethod();
}
}
2)final method
A final method cannot be overridden. Which means even though a subclass can call the final method of parent class without any issues but it cannot override it