两个类 teacher3
public class teacher3{
public String name;
public int age;
public String getName(){
return name;
}
public void setName(String name){
this.name=name;
}
public int getAge(){
return age;
}
public void setAge(int age){
if(age<22){
System.out.println("错误!最小年龄为22岁!");
this.age=22;
}else {
this.age=age;
}
}
public String introduction(){
return "大家好!我是"+name+",我今年"+age+"岁";
}
}
teacher3Test
public class teacher3Test{
public static void main(String[] args){
teacher3 teacher=new teacher3();
teacher.setName("李芳");
teacher.setAge(10);
System.out.println(teacher.introduction());
}
}
这二个类 就是要测试的呀, 为什么 在 eclipse中不能写到一起,如果能写到一起 怎么改,求解答……
|