The final keyword in java is used to restrict the user. The java final keyword can be used in many context.

We have following in Java:

1) final variable
2) final method
3) final class



1) final variable

final variables are nothing but constants. We cannot change the value of a final variable once it is initialized.
Example:


class Bike9{  
  final int speedlimit=90;//final variable  
  void run(){  
  speedlimit=400;  
  }  
  public static void main(String args[]){  
  Bike9 obj=new  Bike9();  
  obj.run();  
  }  
}
Output:   Compile Time Error

2) final method

A final method cannot be overridden. Which means even though a sub class can call the final method of parent class without any issues but it cannot override it.
Example:

class Bike{  
  final void run(){
System.out.println("running safely with 30kmph");
    }  
class Honda extends Bike{  
   void run(){
System.out.println("running safely with 100kmph");
    } 
   public static void main(String args[]){  
   Honda honda= new Honda();  
   honda.run();  
   }  
Output:   Compile Time Error

3) final class

If you make any class as final, you cannot extend it.
Example:

final class Bike{
 }    

class Honda1 extends Bike{  
  void run(){
System.out.println("running safely with 100kmph");
   }      
  public static void main(String args[]){  
  Honda1 honda= new Honda1();  
  honda.run();  
  }  
}  
Output:   Compile Time Error

Points to Remember:
1) A constructor cannot be declared as final.
2) Local final variable must be initializing during declaration.
3) All variables declared in an interface are by default final.
4) We cannot change the value of a final variable.
5) A final method cannot be overridden.
6) A final class not be inherited.
7) If method parameters are declared final then the value of these parameters cannot be changed.