下面的程序加上public就不能运行了 为什么 看不懂 求大神啊
class Test{
public static void main(String[] args){
Person p=new Person("zhangsan",23);
System.out.println(p.getName()+"........."+p.getAge());
}
}
public class Person { //Test.java:8: 错误: 类Person是公共的, 应在名为 Person.java 的文件中声明
private String name;
private int age;
public Person() {
super();
}
public Person(String name, int age) {
super();
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
/*@Override
public String toString() {
return "Person [name=" + name + ", age=" + age + "]";
}*/
/* @Override
public String toString() {
return "Person [name=" + name + ", age=" + age + "]";
}*/
}
|
|