String replace(char oldChar, char newChar) Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar
So on line 3. String reference a will be replaced by a reference to a new String object. The original string "Hellp" that was referred to by a will remain unreferenced in the string literal pool. [ November 04, 2004: Message edited by: Barry Gaunt ]
Thanks! One last question no String objects that are created using a string literal can ever be garbage collected because there will always be a reference from the string pool to the object. correct?
String a = "test"; a = null;
the "test" obj can never be garbage collected while
String a = new String("test"); a = null;
can be garbage collected. [ November 04, 2004: Message edited by: Francis Palattao ]
As far as I know your explanation is correct, provided your class is not dynamically unloaded. And now we are definitely outside the scope of the SCJP.
Post by:autobot
Hey cool! They got a blimp! But I have a tiny ad:
a bit of art, as a gift, that will fit in a stocking