Divine 4 eva
Originally posted by Divine Divine:
tring name;
String newName = "Nick"; // variable newName is pointing to "Nick"
newName = "Jason"; // Now newName is pointing to "Jason" but there is
//no ref for "Nick" - 1st Object for GC
name = "Frieda";
String newestName = name;
name = null; // and the second one is name
//Line A
name = null; // and the second one is name //Line A
thanks,<br />Anju Sethi
Unlike most objects, String literals always have a reference to them from the String Literal Pool (which is a collection of references to String objects), even if there's no longer any active thread that has a reference to that String literal.
Harish<br />SCJP 1.4 (85%)
"If someone asks you to do something you don't know how to, don't tell I don't know, tell I can learn instead." - Myself
String name;
String newName = "Nick";
newName = "Jason";
name = "Frieda";
String newestName = name;
name = null;
//Line A
Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
thanks,<br />Anju Sethi
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Rational Pi Blog - Java, SCJP, Dev Bits- http://rationalpi.wordpress.com
Consider Paul's rocket mass heater. |