Originally posted by Craig Jackson:
At the time the thread reaches the "//here" line of code, wouldn't the object "z" be eligible for GC, since it is no longer pointing toward "y"?
The object "y" will still contain the value 99, but z will not, because it is no longer pointing to "y".
Advise.
References are *not* garbage collected, the objects that they refer to are... The integer object 99 had two references to it. It lost one when the z variable was set to null. It will be eligible for garbaged collection, when the other variable, y, goes out of scope.
Henry
[ June 02, 2006: Message edited by: Henry Wong ]