低于错误:java.lang.IllegalArgumentException:比较方法违反了其一般合同

时间:2016-12-15 10:53:27

标签: java comparison

代码段:

public static List sortReports(List myList) {
    Collections.sort(myList, new Comparator() {
        public int compare(Object obj1, Object obj2) {
            ReportUebersichtParameter o1 = (ReportUebersichtParameter) obj1;
            ReportUebersichtParameter o2 = (ReportUebersichtParameter) obj2;
            int value = o1.getSortCriteria().compareTo(o2.getSortCriteria());
            if (-1 == value) {
                return 1;
            }
            if (1 == value) {
                return -1;
            }
            return o1.getTitel().compareTo(o2.getTitel());
        }
    });
    return myList;
}

无法获得解决方案。有人可以帮忙吗?

0 个答案:

没有答案