Student类:
public class Student {
private String name;
private int age;
public void say(){
System.out.println("名字:"+name+","+"年龄:"+age);
};
public void setName(String _n){
this.name=_n;
}
public String getName(){
return this.name;
};
public void setAge(int _a){
this.age=_a;
}
public int getAge(){
return this.age;
};
}
测试:MainDao类
public class MainDao {
public static void main(String ages[]){
Student s=new Student();
s.setName("Jack");
s.setAge(23);
s.say();
}
}