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???
			
			
									
									
						Garbage Collection
Moderator: admin
- 
				admin
 - Site Admin
 - Posts: 10443
 - Joined: Fri Sep 10, 2010 9:26 pm
 - Contact:
 
Re: Garbage Collection
What do you think and why?
			
			
									
									
						- 
				RRRRRR
 - Posts: 26
 - Joined: Sun Jul 23, 2017 2:13 am
 - Contact:
 
Re: Garbage Collection
Sir, Since I am reading from Kathy Sierra , Bert bates and it is written that there is still a reference to the object referred to by a2 , and there is still a reference to the object referred to by a2.b2 . 
We can still access other Beta object through the static variable a2.b1 -> bcz its static //Can't understand this
			
			
									
									
						We can still access other Beta object through the static variable a2.b1 -> bcz its static //Can't understand this
- 
				admin
 - Site Admin
 - Posts: 10443
 - Joined: Fri Sep 10, 2010 9:26 pm
 - Contact:
 
Re: Garbage Collection
Did you contact the authors of the book? 
What did they say?
			
			
									
									
						What did they say?
Who is online
Users browsing this forum: No registered users and 37 guests