heyipomoea 2013-08-10 06:07
浏览 1905

Collections.sort疑问

JButton btnNewButton = new JButton("排序");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Collections.sort(studentList, new ChineseComparator());
}
});

想请问版上大哥,上列是我使用event的写法,我想要将studentList中的资料排序

但是却出现error,不知道为什么...error错误讯息是The method sort(List, Comparator<? super T>Wink in the type Collections is not applicable for the arguments (List, ChineseComparator)...

我看网路上都是这样写都可以阿...会是<? super T>的问题吗?

并附上ChineseComparator的写法

public class ChineseComparator implements Comparator {

@Override
public int compare(Student s1, Student s2) {
// TODO Auto-generated method stub
if (s1.getChnScore() > s2.getChnScore())
return 1;
else if (s1.getChnScore() < s2.getChnScore())
return -1;
else
return 0;
}
}

麻烦了

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向