The following question is from a mock exam. 1.String string1 = "Test"; 2.String string2 = "Today"; 3.string1 = null; 4.string1 = string2; How many objects will be garbage collected after Line//4. The answer given is 1 But i think the answer should be 0
Friends, whether it is on heap or string pool, it still occupies memory correct, which needs to reclaimed, so what is wrong in reclaiming those unused memories of string pool. otherwise string pool will go out of memory after some time. i welcome explanations which can through further light on the topic.
Joined: Apr 17, 2001
G there is nothing wrong in memory reclamation, just that String objects created in the pool are not GC'ed but the objects created on the heap are. Pick up a bone with Sun people if you have any problems with that. I a'int getting into that fight.