Final Modifier Assures that a Reference variable cannot be referenced to a different Object

 public class Main 
   public int Age;
   public static void main(String args[])
     final Main objMain = new Main();
     Main objMain2 = new Main();
     objMain = objMain2;

OP:Generates a Exception
The final local variable objMain cannot be assigned.

Leave a reply