当前位置: 代码迷 >> J2SE >> 又来麻烦大家了,一个很基础的有关问题
  详细解决方案

又来麻烦大家了,一个很基础的有关问题

热度:52   发布时间:2016-04-24 14:11:51.0
又来麻烦大家了,一个很基础的问题
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();
}不能通过编译,这是为什么呢?

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

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