public class Student {
private String name;
private int age;
public Student(){
this.name = "";
this.age = 0 ;
}
public Student(String name,int age){
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;
}
public void show(){
System.out.println(name+"---"+age);
}
}
public class StudentTest{
public static void main(String[]args){
Student s1 = new Student();
s1.setname("张晓文");
s1.setage(24);
System.out.println(s1.getname()+"--"+s1.getage());
s1.show();
}
}
补充:The public type StduentTest must be defined in its own file
请问在eclipse中怎么解决??就是最后定义的一个测试类,它说我没有在文件中定义。 |
|