日期:2014-05-20  浏览次数:20690 次

this为什么不可以这样传递?
class   hu
{
private   int   age;
void   fun()
{
System.out.println( "hufang   age   is "+age);
}
  void   fun1(hu   a)
{
a.fun();

}


public   static   void   main(String   []   args)
{
hu   hudawei   =new   hu();
hu   huna=new   hu();
hudawei.fun1(this);
}
}
this当成调用fun1的对象传递有错吗?为什么会出错啊?

------解决方案--------------------
this不能用在static方法里。

因为那个时候this还没有出生呢