I am bit confused whether objects are garbage collected or variables also. Refer Khalid Mughal page 252 import java.io.*; void wellbehavedClasss { void wellbehavedMethod() { File aFile; long[] bigarray = new long[20000]; afile = null; // 1 bigArray = null //2 book say 2 objects will be ready for garbage collection but it say that objects created using new operator are monitered by automatic garbage collector method. Please explain. Mahesh
James Baud
Ranch Hand
Joined: Jan 06, 2001
Posts: 60
posted
0
aFile and bigArray are simply variables that denote references to objects. After (1) & (2) and before any other intensive activity, the objects that these variables are denoting/referencing will be eligible for garbage collection. This also means these variables are still available for other assignments, if needed. [This message has been edited by James Baud (edited January 12, 2001).]
<B>~James Baud</B><P>He who asks, is a fool for five minutes;<BR>but, he who does not ask, remains a fool forever. (Chinese proverb)