Could someone explain why the member "a" is not eligible for garbage collection after line 8.
1. public void method() {
2.
String a,b;
3. a = new String("hello world");
4. b = new String("good bye");
5. System.out.println(a+b + "!");
6. a = null;
7. a = b;
8. System.out.println(a);
9. }
In the absence of optimization, after which earliest line the object a is definitly elibible to be garbage collected?
I anwered line 8.
The answer is line 6.
Please explain.
}