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

又来麻烦大家了,一个很基础的问题
class   bow{
int   a;
void   prit(){
System.out.println( "a 's   number   is   "+a);
}
}

public   class   one{
bow   b=new   bow();
}
能编译过

class   bow{
int   a;
System.out.println( "a 's   number   is   "+a);
}

public   class   one{
bow   b=new   bow();
}不能通过编译,这是为什么呢?

------解决方案--------------------
执行必须放在方法中。

------解决方案--------------------
类里是不能直接执行方法的