public class Test{
public static void main(String[]args){
//按照学生年龄存储自定义对象
TreeMap<Student,String> tm = new TreeMap<Student,String>(new Comparator(){
@Override
public int compare(Student s1,Student s2){
int num=s1.getAge()-s2.getAge();
int num2=(num==0)?s1.name.compareTo(s2.name):num;
return num2;
}
}
);