对象和字段自定义
/** * 判断List<Knowledge>的对象code是否有重复,有重复true * * @param orderList * @return */ private Boolean knowledgeIsRepeat(List<Knowledge> orderList) { Set<Knowledge> set = new TreeSet<Knowledge>(new Comparator<Knowledge>() { public int compare(Knowledge a, Knowledge b) { // 字符串则按照asicc码升序排列 return a.getCode().compareTo(b.getCode()); } }); set.addAll(orderList); if (set.size() < orderList.size()) { return true; } return false; }