SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD, SCEA/OCMJEA
Live life to an interface, not an implementation!
A reference to that String object will be retained in the runtime constant pool, as with other String literals.One String object will be eligable for garbage collection, "Nick".
One String object will be eligible for collection i.e. "nick"
code:
--------------------------------------------------------------------------------
Object v1; Object v2 = new Object(); // <-- o1 v2 = new Object(); // <-- o2 v1 = new Object(); // <-- o3 Object v3 = v1; v1 = null; //Line A
--------------------------------------------------------------------------------
Jignesh Raval
Originally posted by Kanchan K Bulbule:
As per your example reference to Nick is lost
" String newName = "Nick";
newName = "Jason"; "
So "Object Nick " is available for Garbage Collection
it looks like String and Object are different in Garbage Collection?
Get meta with me! What pursues us is our own obsessions! But not this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
|