// 删除ArrayList中重复元素,保持顺序
public static List<Map<String, Object>> removeDuplicateWithOrder(List<Map<String, Object>> list) {
Set<Map<String, Object>> set = new HashSet<Map<String, Object>>();
List<Map<String, Object>> newList = new ArrayList<Map<String,Object>>();
for (Iterator<Map<String, Object>> iter = list.iterator(); iter.hasNext();) {
Map<String, Object> element =iter.next();
if (set.add(element))
newList.add(element);
}
list.clear();
list.addAll(newList);
return list;
}
转载于:https://www.cnblogs.com/renpei/p/9647750.html