class Number{
int i;
}
public class Assignment{
public static void main(String[] args){
Number n1=new Number();
Number n2=new Number();
n1.i=9;
n2.i=47;
System.out.println( "1:n1.i: "+n1.i+ ",n2.i: "+n2.i);
n1=n2;
System.out.println( "2:n1.i: "+n1.i+ ".,n2.i: "+n2.i);
n1.i=27;
System.out.println( "3:n1.i: "+n1.i+ ",n2.i: "+n2.i);
}
}
问:为什么我编译后,出现:Number.java:5: 类Assignment是公共的,应在名为Assignment.java的文件中声明public class Assignment{
^
1 错误
为什么呀~~~??我明明public了呀,想不通了~~~~~??
------解决方案--------------------
把这个文件的名称改成Assignment.java
------解决方案--------------------
每个类里面有切只能有一个public class类,