去重复 resultList = treasuryManager.queryAllTreasury(sMap); List remList = new ArrayList(); Set retList = new HashSet(); CStorageRate csr = new CStorageRate(); CStorageRate csr1 = new CStorageRate(); //去掉入库日期重复的,同一日期只保留一种 for(int i = 0 ; i<resultList.size();i++){ csr = (CStorageRate) resultList.get(i); for(int j = i+1 ; j<resultList.size();j++){ csr1 = (CStorageRate) resultList.get(j); if(csr.getEnterDate().equals(csr1.getEnterDate())){ remList.add(csr1); } } } resultList.removeAll(remList); 过滤掉了包含指定重复字段的对象。 问题:查询返回的list集合保存的是对象,去掉这些对象中empid重复的对象,只保留不重复的。 List resultList = new ArrayList(); List currentEmpList = new ArrayList(); currentEmpList = performanceDao.queryAllEmpOfCurrDateNew(curdate); // 用开始日期和结束日期为范围,查询已经维护了日历项的(可能一个人有多条) //去掉重复的&取出empid放入新的集合(集合元素类型未Integer) for(int i = 0 ;i<currentEmpList.size(); i++){ TNotesCalendarinfo tnc = (TNotesCalendarinfo) currentEmpList.get(i); System.out.println(tnc.getEmpid()+" datalist: "+tnc.getDatalist()); if(tnc.getDatalist()==null){ if(resultList.contains(tnc.getEmpid())){ }else{ resultList.add(tnc.getEmpid()); } }else{ if(tnc.getDatalist().indexOf(curdate) > -1){ if(resultList.contains(tnc.getEmpid())){ }else{ resultList.add(tnc.getEmpid()); } } } }