package nba.com;
public class Student {
/**
* @param args
*/
private int id;
private String name;
private String clas;
public Student() { //无参构造方法
}
public Student(int id, String name, String clas) { //有参构造方法
super();
// TODO Auto-generated constructor stub
this.id = id;
this.name = name;
this.clas = clas;
}
public String getClas() {
return clas;
}
public void setClas(String clas) {
this.clas = clas;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Student st = new Student(1, "xiao", "三年七班");
System.out.println("学号是:" + st.id);
System.out.println("名字是:" + st.name);
System.out.println("班级是:" + st.clas);
// 这两个是一样的测试
Student st2 = new Student();
st2.setId(1);
st2.setName("梁永刚");
st2.setClas("三年七班");
System.out.println("这位同学的学号是:" + st2.getId() + " ,名字是:" + st2.getName()
+ ",班级是:" + st2.getClas());
}
}
参考资料:自己