final, finally and finalize in Java

final:

final is a keyword that is used to apply restrictions on class, method and variable.

Example:

final int number =50; // final variable
final void add()      // final method
{
 ...........
 ...........
}
final class test     // final class
{
 ........
 ........
}

finally:

finally is a block that is used to place important code that will be executed whether execution is handled or not.

Example:

try 
{
  Statement;  // generates an exception
}
catch(Exception-type e)
{
  Statement; //Handling exception
}
finally 
{
  Statement; //execution Statement
}

finalize:

finalize is a method that is used to perform cleanup processing hust before the object is garbage collected.

Example:

public class test
{  
  public static void main(String args[])   
    {   
      test t1 = new test();    
      t1 = null;    
      System.gc();   
      System.out.println("Garbage Collection");   
  }   
    public void finalize()   
    {   
      System.out.println("Finalize Method");   
    }   
}  

Output:

Finalize Method
Garbage Collection