Originally posted by Srinivasa Raghavan:
I agree none are eligible for GC.
But if the findOut() is modified like the one below then 2 objects are eligible for garbage collection , am i right ?
Originally posted by Manish Nijhawan:
As you have explained that at the commented line since all the objects have the references so they are not eligible for the GC. But since that line is the last line of the method , so after that line all the references to all the objects will vanish , so all the Live objects should be eligible for GC.
Please explain me this as i am very much confused about GC.
Originally posted by nish vats:
According to me only one object will be elgible for garbage collection..i.e
this object has refernce count =0;as u can check .Intially this object was refrenced by x but when x=y is executed .This object is no longer refrenced.
new Integer(99) is being still refernced by y.so only one object is elgible for garbage collection