给定下面的代码。
class A {
private B b;
public A() {
b = new B();
}
}
class Main {
public static void main(String[] args) {
A a = new A(); // two objects are created (a and b)
// <-- is B object, referenced only by private a.b eligible for garbage collection?
keepAlive(a);
}
}
A对象创建后B对象可以被垃圾回收吗?