Hi Everybody,
Consider the following program,originally created by Antti Barck
result:Finalize:CombineSimple
Here, getSimple() in combine class returns an object of Simple class,
therefore according to me two references for Simple class object exists,
(1)One in private object reference variable
obj of
CombineSimple (2)Second in
bah a Simple class object reference variable in
UseSimple's main method.
If I set
har=null, which is an object reference variable for
CombineSimple,then a call to System.gc() invokes the finalize method for this object.Now my question is what happens to private variable obj of CombineSimple at the time of GC, since this variable and the variable
bah in main both refer to same Simple object,
will obj be set to null by the GCwhen it is forcefully called, thereby reducing the number of references to Simple object in heap, to one or will it do something else ?
Please help....
THANKS
[This message has been edited by Bindesh Vijayan (edited August 29, 2001).]
[This message has been edited by Bindesh Vijayan (edited August 30, 2001).]