5. class Rubbish {
6. Rubbish r;
7. public static void main(String [] args) {
8. Rubbish r1 = new Rubbish();
9. Rubbish r2 = new Rubbish();
10. Rubbish r3 = new Rubbish();
11. r1.r = r2; r2.r = r3; r3.r = r1;
12. r3 = null;
13. r2 = null;
14. r1 = null;
15. // do stuff
16. }
17. }
/*
Location: ... > Section 7: Fundamentals > Objective 7.4 > Question 65
Given:
After which line does the first object become eligible for garbage collection?
A after line 11
B after line 12
C after line 13
D after line 14
E Compilation fails.
Option D is correct. NOT until line 14 are any objects inaccessible from a live thread.
*/
Eu não consegui entender o fluxo do programa… Eu pensei que após a linha 13 é que tenho o primeiro objeto elegível para o GC.
Se alguém puder ajudar…
Desde já Agradeço…
