给出以下代码。
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 对象可以被垃圾回收吗?