Two Laptop Bag*
The moose likes Java in General and the fly likes which objects are eligible for Garbage Collection? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "which objects are eligible for Garbage Collection?" Watch "which objects are eligible for Garbage Collection?" New topic
Author

which objects are eligible for Garbage Collection?

abhinav sinha
Greenhorn

Joined: Nov 29, 2007
Posts: 22
Following is a piece of code -

<code>

public class BettyAck {
public static void main(String argv[]){
BettyAck b =new BettyAck();
}
public BettyAck() {
Integer x = new Integer(10);
findOut(x);
Integer y = new Integer(99);
Integer z = y;
z = null;
findOut(y);
//here
}
public void findOut(Integer y){
y = null;

}

<\code>

I came to know that on the line " //here " in the above code,none of the objects will be eligible for garbage collection but I am not convinced with explanation given.Please can anyone explain me clearly why is it so?
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3429
    
  12
What was the explanation given ?
Why were you not convinced by it ?
Which objects do you think are eligible for garbage collection ?


Joanne
abhinav sinha
Greenhorn

Joined: Nov 29, 2007
Posts: 22
I do not exactly remember the explanation because I could not exactly understand it.I feel both objects are eligible for garbage collection but I know thats not the correct answer.Please can you give me the correct and a lucid and simple explanation?
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3429
    
  12
You need to show you've put some effort into finding the answer, such as searching for similar questions on these forums. BettyAck is a good search term.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: which objects are eligible for Garbage Collection?
 
Similar Threads
Garbage Collection
confused............
can anyone explain this?
GC Question from Marcus Green
Garbage Collection