Garbage Collection
Posted: Sat Aug 05, 2017 6:21 am
Sir my question is->
class Beta{}
class Alpha
{
static Beta b1;
Beta b2;
}
class Tester
{
public static void main(String[] args)
{
Beta b1=new Beta();
Beta b2=new Beta();
Alpha a1=new Alpha();
Alpha a1=new Alpha();
a1.b1=b1;
a1.b2=b1;
a2.b2=b2;
a1=null; b1=null; b2=null;
//doStuff
}
}
When line doStuff is reached there is only 1 Object eligible for Garbage Collection. Why???
class Beta{}
class Alpha
{
static Beta b1;
Beta b2;
}
class Tester
{
public static void main(String[] args)
{
Beta b1=new Beta();
Beta b2=new Beta();
Alpha a1=new Alpha();
Alpha a1=new Alpha();
a1.b1=b1;
a1.b2=b1;
a2.b2=b2;
a1=null; b1=null; b2=null;
//doStuff
}
}
When line doStuff is reached there is only 1 Object eligible for Garbage Collection. Why???