JAVA一个程序中为什么规定只能有一个公共类?main()方法必须写在这个公共类中,不能写在非公共类中吗?[解决
JAVA一个程序中为什么规定只能有一个公共类?
main()方法必须写在这个公共类中,不能写在非公共类中吗?
[解决办法]
public class test {
}
class test2
{
public static void main(String arg[]) {
System.out.println(1);
}
}
可以写在非公共类里
问题是你运行的时候,需要指向非公共类
如上例子
