返回列表 发帖

菜鸟问题

class myclass {
        public int x;
        myclass(){
                x=0;
        }
        public void saysomething(){
                System.out.println("welcome to here");
                }
}
public class test {
        public static void main(String args[]){
        myclass test1=new myclass();
        System.out.println(test1.x);
        test1.saysomething();
        }
}
我创建的类是myclass,为什么有错说是“the public type test must be defined in its own file ”??
分享到: QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友

程序本身是没有问题的,就是那个test的类为什么要从另外的文件中定义??

TOP

基本上一个文件一个类。

TOP

返回列表