Float f = new Float(3.5f); Float f = new Float(3.0f); f = null; f= null; When is object referenced f eligable for g.c? How many objects are eligable for g.c. I think there are 2 objects eligable for g.c. First the Float(3.5f) and then the last reference Of f which is Float(3.0f). Is that correct? What is the earliest point when f is eligable for g.c. is it line 3? Appreciate your answers. Thomas
Blake Minghelli
Ranch Hand
Joined: Sep 13, 2002
Posts: 331
posted
0
Do you mean to name your references as f1 and f2... you have them both named as f???
Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
Thomas Markl
Ranch Hand
Joined: Mar 08, 2001
Posts: 192
posted
0
The references are both "f" in this question.
Blake Minghelli
Ranch Hand
Joined: Sep 13, 2002
Posts: 331
posted
0
Float f = new Float(3.5f); Float f = new Float(3.0f); f = null; f= null;
Ok, just trying to make sure I understand. Since you can't declare the same variable twice, I think you mean...
Is that correct? If so, then I believe your first object (3.5) is eligible for gc at line 4, and your second object (3.0) is eligible at line 5.
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
posted
0
The references are both "f" in this question. As Blake implied, such a program fragment would produce a compile-time error. Where did you find this example?