我有以下代码:
public class Test {
public static void main(String[] args) {
SomeClass oneInstance = new SomeClass();
oneInstance.otherInstance = new SomeClass();
oneInstance = null;
}
}
class SomeClass {
public SomeClass otherInstance;
}
我知道JVM会在两个创建的对象上启动垃圾收集器,但是otherInstance引用会发生什么?它仍应指向第二个对象