[java]代码库
package TREE;
public class Person_JavaBean implements Comparable<Person_JavaBean> {
private String name;
private String age;
private String number;
public Person_JavaBean() {
super();
}
public Person_JavaBean(String name, String age, String number) {
super();
this.name = name;
this.age = age;
this.number = number;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
/**
* 重写toString方法
*/
public String toString() {
return "姓名:" + name + "\t年龄:" + age + "\t学号:" + number;
}
/**
* 重新Comparable接口中compareTo方法 Person_JavaBean 待比较对象
*/
@Override
public int compareTo(Person_JavaBean o) {
// TODO Auto-generated method stub
return age.compareTo(o.age);
}
}