2 objects are created. one in the heap and another "abc" in the string pool.
I have a doubt that if we assign null to s1 (s1=null then object created
in the string pool is available for garbage collection or not.
Please give the detailed explanation ....
Thanks in advance
Joined: Oct 10, 2005
Here's some information to you hari, The object gc takes the object only when there are no references to it(internal or external). You cannot be sure when gc will be called and when it acts. This is what I think if I am not mistaken. Other ranchers please correct me if I am wrong.
Actually this thread got hijacked from counting total number of objects created to total number of objects GC'd
Totally there are 3 objects ( 2 String buffers ) & a String in the StringPool.When S1 is set to null then only the StringBuffer pointed by s1 is eligible for GC and not the string in the string pool [ December 15, 2005: Message edited by: Srinivasa Raghavan ]