Hi, 1)My Question is Strings are immutable objects right?means we can't modify the object why because string is adding into stringpool every time we declare a new string if and if there is no string with the same name other wise it create one new reference for our string.that's why we can't chage the string. 2)Grabagecollector will not work on stringpool right?
Now my Question is who is going to reclaim the memory of stringpool on the heap ?
Whether garbage collectors collect objects in a string pool is implementation dependent. It is highly unlikely that a question on garbage collection of string pool literals appears in the exam. As far as the exam is concerned, please be sure that any object (even Strings) for which there are no live references will be garbage collected.
"coffee", please read our JavaRanch Naming Policy and change your displayed name to comply with it. We require a name in the format <first name><space><family name>, preferably your real name. After a few more posts, your profile will be disabled if you continue without changing your displayed name. Thanks -Barry
Hi, Let me thank first for you answeres.Guys so far my Question is not cleared. As per language specification GrabageCollector won't invoke in Stringpool for to clear unused string objects.My Question is who is going to clean those String objects ? Regards, G Sirish Reddy.,
Hi, I think OS would reclaim the memory as soon as JVM ends. although not sure..
Regards<br />Sandy<br />[SCJP 5.0 - 75%]<br />[SCWCD 1.4 - 85%]<br />------------------<br />Tiger, Tiger burning bright,<br />Like a geek who works all night,<br />What new-fangled bit or byte,<br />Could ease the hacker's weary plight?