TreeSet和TreeMap
本章节仅展示TreeSet
展示在内部比较器下显示的结果
1.1 创建Student类并实现内部比较器
import java.util.Objects;
/**
* 创建一个Student的javaBean对象 实现内部比较器
*/
public class Student implements Comparable<Student>{
private int sno; //学号
private String name; //姓名
private int age; //年龄
private int score; //成绩
public Student() {
}
public Student(int sno, String name, int age, int score) {
this.sno = sno;
this.name = name;
this.age = age;
this.score = score;
}
public int getSno() {
return sno;
}
public void setSno(int sno) {
this.sno = sno;
}
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;