当前位置: 技术问答>java相关
垃圾收集器一题!??
来源: 互联网 发布时间:2015-03-09
本文导语: public class x { public Object m() { Object o = new Float(3.14F); Object [] oa = new Object[1]; oa[0]=0; o=null; return oa[0]; } } when is the Float object ,created in line 3,eligible for garbage collection? a.just after line 5 b.just after li...
public class x
{
public Object m() {
Object o = new Float(3.14F);
Object [] oa = new Object[1];
oa[0]=0;
o=null;
return oa[0];
}
}
when is the Float object ,created in line 3,eligible for garbage collection?
a.just after line 5
b.just after line 6
c.just after line 7(that is,as the method returns)
d.never in this mothod
我认为选d,对吗?
{
public Object m() {
Object o = new Float(3.14F);
Object [] oa = new Object[1];
oa[0]=0;
o=null;
return oa[0];
}
}
when is the Float object ,created in line 3,eligible for garbage collection?
a.just after line 5
b.just after line 6
c.just after line 7(that is,as the method returns)
d.never in this mothod
我认为选d,对吗?
|
oa[0]=0;还是oa[0]=o;
|
oa[0]=0;你这行是不是打错了,应该是
oa[0]=o;
oa[0]=o;
|
你那个oa[0]=0;应该是oa[0]=o;吧
如果是这样的话,选D
如果没写错,我认为选B
如果是这样的话,选D
如果没写错,我认为选B