程序如下,问在第几地或者哪几行执行完有可能执行垃圾回收:
class Test
{
public static void main(String[] args){
1. Test a=new Test();
2. Test b=new Test();
3. Test c=new Test();
4. a=b;
5. a=c;
6. c=null;
7. a=null;
}
}

解决方案 »

  1.   

    class   Test 

    public   static   void   main(String[]   args){ 
    1. Test   a=new   Test(); 
    2. Test   b=new   Test(); 
    3. Test   c=new   Test(); 
    4. a=b; // a以前的对象可以被回收
    5. a=c; 
    6. c=null; 
    7. a=null; // c以前的对象可以被回收 

    }
      

  2.   


    为什么有这个呀: a=b;   //   a以前的对象可以被回收我不太同意的,但下一个答案我也认可...