I am doing some exercises, I did one that I don't know the answer. ;-)
Given this exercises:
Exercise Two: (Equal than before but with "hl" as static var.)
The questions are:
 Is in exercise one the object "t" create in line 14 eligible for GC?
 Is in exercise two the object "t" create in line 14 eligible for GC?
 For me YES. "hl" (Highlander) is an instance of the object that GC want to "destroy". This is an "Island of isolation", so, threre are two object two "destroy".
 I don't know! I need some help! ;-)
Please, correct me if I'm wrong. And help for the second question!
Alam Ameghino wrote:
Yes, of course. It is not private.
But, in this excercise there is not such access.
So, "hl" elegible for GC?
Henry, a lot of thanks!
Sorry, I am out of hints... so here is the answer. I was actually hoping that you get it by yourself, as people tend to remember better when they do figure it out.
You can access static variables of a class without an instance. In this case, you can access the object referenced by the "hl" variable of the Test class via "Test.hl". This means that the object is still reachable, and hence, not eligible for GC.