@Override
public int compare(Object o1, Object o2) {
if (!(o1 instanceof Pp)) {
throw new ClassCastException();
}
if (!(o2 instanceof Pp)) {
throw new ClassCastException();
}
Pp p = (Pp) o1;
Pp p1 = (Pp) o2;
int num = p.age - p1.age;
return num == 0 ? p.name.compareTo(p1.name) : num;
// return 0;
}
Java集合类的详解与应用(4)
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:https://www.heiqu.com/c959fe486945ef52ddac77b2aa651187.html