User:Kolkata refresh

public class GC { public GC { System.out.println(this+" created"); }  protected void finalize { System.out.println(this+" is removing"); }   public static void main(String args[]) { GC a=new GC; //1st object GC b=new GC; //2nd object a=b; //1st object becomes garbage collectable System.gc; // calling garbage collection process System.out.println("1st object removed"); a=b=null; //2nd object becomes garbage collectable System.gc; // calling garbage collection process System.out.println("2nd object removed"); } }