标签:学生 object 新建 alt 提交代码 列表 dcom inf tor
要求:针对下面的Student类,使用Comparator编程完成以下功能:
import java.util.Comparator;
public class IDComparator implements Comparator {
@Override
public int compare(Object o1, Object o2) {
Student st1 = (Student)o1;
Student st2 = (Student)o2;
return (Integer.parseInt(st1.getId())-Integer.parseInt(st2.getId()));
}
}
import java.util.Comparator;
public class scoreComparator implements Comparator {
@Override
public int compare(Object o1, Object o2) {
Student st1 = (Student)o1;
Student st2 = (Student)o2;
return (int) (st1.getTotalScore()-st2.getTotalScore());
}
}
https://gitee.com/BESTI-IS-JAVA-2018/20165337/tree/master/week10buzuo
标签:学生 object 新建 alt 提交代码 列表 dcom inf tor
原文地址:https://www.cnblogs.com/y963976867/p/9000345.html