public static void main(String[] args) {
Student10 st10 = new Student10(“张三”, 23, 1.73);
Student10 st11 = new Student10(“张三丰”, 99, 1.80);
Student10 st12 = new Student10(“李淳风”, 99, 1.78);
Student10[] stss = {st10, st11, st12};
Arrays.sort(stss, new Comparator<Student10>() {
@Override
public int compare(Student10 o1, Student10 o2) {
double temp = o1.getAge() - o2.getAge();
temp = temp == 0 ? o1.getHight() - o2.getHight() : temp;
temp = temp == 0 ? o1.getName().compareTo(o2.getName()) : temp;
if (temp > 0) {
return 1;
} else if (temp < 0) {
return -1;
} else {
return 0;
}
}
});
System.out.println(Arrays.toString(stss));
}