Originally posted by eric lee:
Hi,Don Bosco,how about line 6, is line 6 eligible
for garbage collection? (o=null),thanks
1 class m {
2 public Object m () {
3 object o = new Integer (10);
4 object [] oa = new object [1];
5 oa[0]= o;
6 o = null;
7 return oa[0];
8 }
9 public static void main(String s[]){
10 m m1 = new m();
11 Object ob = m1.m;
12 ob = "Don Bosco";
}
}
o and oa[0] both point to same OBJECT before line6.
at line6 o is made to point null. but since oa[0] still points to that OBJECT, the OBJECT is not eligible for garbage collection.
remember that garbage collection is done on OBJECTS, not on references.
[ December 03, 2002: Message edited by: Don Bosco ]