标题: 学习笔记 [打印本页] 作者: heqinghui 时间: 2019-9-25 21:32 标题: 学习笔记 TreeSet<Teacher>ts = new TreeSet<>(new Comparator<Teacher>() {
@Override
public int compare(Teacher s1, Teacher s2) {
int num = s2.getSum()-s1.getSum();
int num2 = num ==0?s1.getName().compareTo(s2.getName()):num;
return num2;
}
});
Teacher t1 = new Teacher("cangjingkong",98,99);
Teacher t2 = new Teacher("xiaozemaliya",100,99);
Teacher t3 = new Teacher("qiaobenhuannai",98,100);
Teacher t4 = new Teacher("boduoyejieyi",99,98);
Teacher t5 = new Teacher("nongzeluola",85,95);
Teacher t6 = new Teacher("jizemingbu",100,100);