Just Do Study - IGNOU Assignments Site: Java Tutorials: Finalize and Garbage Collector Example

Saturday 6 October 2012

Java Tutorials: Finalize and Garbage Collector Example

class TT extends Object
{
 TT()
 {
 System.out.println("TT Class Default Constructor ");
 }
 protected void finalize()
 {
 System.out.println("TT Object Going to Dead....");
 }
}
 public class SystemClassDemo3 {
 public static void main(String args[])
 {
 TT obj = new TT(); // Strong Reference
 System.gc();
 System.out.println("Now I am Going to Null the Obj ");
 obj = null;
 System.gc();
 System.runFinalization();
 }
}

No comments:

Post a Comment