This week's book giveaways are in the Refactoring and Agile forums. We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line! See this thread and this one for details.
Garage collector runs whenever an object is not in a reachable position.That can be achieived through disconnecting the link between object and reference variable.
I have a example.
Line1:Integer y=new Integer(567);
In the above example a new object is created at line1.We unwrap the primitive and modify the primitive value at line 2 and line3.At line4 another instance is created and assigned to same reference variable y.So now reference variable y points to new object.Then object created at line1 becomes eligible for garbage collection.Is this right?