Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
a beginner in java
giddee up
giddee up
a beginner in java
a beginner in java
giddee up
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
giddee up
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
giddee up
giddee up
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
giddee up
Originally posted by Peter den Haan: (referring to the additional code i posted)
It is after the statement on line 6, i.e. at line 7, that the first Employee can be garbage collected.
- Peter
giddee up
Originally posted by Bert Bates:
1. class X2 {
2. public X2 x;
3. public static void main(String [] args) {
4. X2 x2 = new X2();
5. X2 x3 = new X2();
6. x2.x = x3;
7. x3.x = x2;
8. x2 = new X2();
9. x3 = x2;
10. doComplexStuff();
11. }
12. }
look at line 6:
x2.x = x3;
What this line says is: 'The object referred to by x2 has a reference variable x ('x2.x'). Set this reference variable (x2.x) equal to the reference variable x3, which refers to the second X2 object (the one created in line 5).
hmm - i would surmise that the first X2 object is still alive so far, even tho x2.x refers to the second X2 object? Because what does x2 refer to at this stage?
and on line 7, that first object is referred to by x3.x = x2?
We know the following about line 6:
As far as line 6 is concerned, there is one object and there are two reference variables.
So, as of that moment there are two ways to refer to that one object:
x3 or x2.x // they both refer to the same object !!!
giddee up
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Originally posted by Bert Bates:
Jasper -
The objects created on lines 4 and 5 still exist, (probably, the GC isn't THAT fast), and those two objects refer to each other, but how can YOU refer to them?
giddee up
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
giddee up
giddee up