System.out.println(tm);
}
public class Student implements Comparable<Student> { //Student实现了Comparable接口 重写了CompareTo方法
private String name;
private int age;
public Student() {
super();
}
public Student(String name, int age) {
super();
this.name = name;
this.age = age;
}
@Override
public int compareTo(Student o) { // 重写了CompareTo方法
int num = this.age - o.age; //以年龄为主要条件
return num == 0 ? this.name.compareTo(o.name) : num;
}
}