小编sha*_*wat的帖子

java垃圾回收

我在SCJP准备网站上经历了这个问题.答案A如何正确?

a,b,aa在标有"// some code goes here"的行引用的对象的真实情况是什么?

class A {
    private B b;
    public A() {
        this.b = new B(this);
    }
}

class B {
    private A a;
    public B(A a) {
        this.a = a;
    }
}

public class Test { 
    public static void main(String args[]) {
        A aa = new A();
        aa = null;
        // some code goes here
    }
}


A) The objects referenced by a and b are eligible for garbage collection.
B) None of these objects are …
Run Code Online (Sandbox Code Playgroud)

java garbage-collection

5
推荐指数
1
解决办法
596
查看次数

标签 统计

garbage-collection ×1

java ×1