Topic: 一个“垃圾回收机制”问题!!

  Print this page

1.一个“垃圾回收机制”问题!! Copy to clipboard
Posted by: 1332185
Posted on: 2006-06-01 16:00

1. class Bar{}
2. class Test{
3. Bar doBar(){
4. Bar b=new Bar();
5. return b;
6. }
7. public static void main(String args[]){
8. Test t=new Test();
9. Bar newBar=t.doBar();
10.System.out.println("newBar");
11.newBar=new Bar();
12.System.out.println("finishing");
13.}
14.}
各位大哥,我是刚学java不久,我现在对这个程序有2处地方不懂。
1:第3行“Bar doBar()”这个方法,我不知道它是个什么方法?它的返回值是什么类型?
2:这个程序满足垃圾回收机制的有那些?

请各位大哥教教我。我刚学不久,请说详细点。谢谢!!!

2.Re:一个“垃圾回收机制”问题!! [Re: 1332185] Copy to clipboard
Posted by: tomcatexpert
Posted on: 2006-06-02 14:51

1. Bar doBar() --> create a fresh new instance of Bar object.. return type is Bar.

2. when line 11. is executed, the first Bar object is eligible for GC.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923