posted 20 years ago
Hi Kaleem,
Kindly refer to your code. It will not compile due to error in line # 5 and the return type of the haq should be "Object" and not "object". I have changed the line # as <code>obj1[0]=obj;</code>
Anyway, what I understand from the code. The Float object pointed by reference "obj" will be garbage collected only after the return from the function. The reason is that at line # 5 the Float object (2.14F) can be accessed by two refernces viz., obj and obj1[0]. After the execution of line # 6. The connection to Float(2.14F) is de-refferenced by the obj. But, the object can still be reached by the reference obj1[0], so the same is still not eligible for GC. At line # 7 you are returning the object's reference to the callee function, so "null" is returned. Finally, at line # 8, the function returns so , the GC must release all the locally created object's that are unreacheable , in the current code this means that Float(2.14F) object must be GC'ed.
Hope this clears your doubt.
Ravindra Mohan.
[This message has been edited by Ravindra Mohan (edited September 27, 2001).]