列表去重统计重复次数

Map<String,Object> courseMap = new HashMap<>();
for(vo tv: volist){
String key = tv.getCourseId() + "_" + tv.getCalendarId() + "_" + tv.getClassId();
String value = tv.getContent() + "(" + 1 + ")";
boolean flag = courseMap.containsKey(key);
if (flag) {
int courseNum=1;
String content = (String) courseMap.get(key);
String[] split = content.split("\\(");
courseNum = Integer.parseInt(split[1].split("\\)")[0]);
courseNum++;
value = tv.getContent() + "(" + courseNum + ")";
}
courseMap.put(key, value);

}

posted on 2017-09-19 11:41  miu丶苏  阅读(160)  评论(0编辑  收藏  举报

导航