Originally posted by srinivas sridaragaddi: Hi, I thought both newestname and name both are eligible but only name is eligible for collection. Does it mean that only explicitly null assigned strings are eligible for garbage collection.
newestName is not eligible because it has its reference pointing to the name String Object, not null. To take it a step farther, name is not eligible for GC either because it has a reference from newestName. Assigning newestName to null will make them both eligible.
Hope this helps... Aloha, Doug
It sure was nice of your sister to lend us her car. Let's show our appreciation by sharing this tiny ad: