Sunday, March 1, 2009

Garbage collector internal references



package funds;

public class Test {
Test i;
public static void main(String arg[])
{
Test t1=new Test();
Test t2=new Test();
Test t3=new Test();
t1.i=t2;
t2.i=t3;
t3.i=t1;
t1=null; // no object is eligible for Garbage collector
t2=null; //no object is eligible for Garbage collector
t3=null; //All three objects are eligible for Garbage collector
}
}



0 comments:

Post a Comment