map里的list中的对象相同的数据进行分组
Object o=new Object();
o.name="aa";
Object o1=new Object();
o1.name="aa";
Object o2=new Object();
o2.name="bb";
Object o3=new Object();
o3.name="bb";
Object o4=new Object();
o4.name="bb";
Object o5=new Object();
o5.name="bb";
List<Object> list = new ArrayList<>();
Map<String, List<Object>> map= new HashMap<>();
Iterator<Object> iterator = list.iterator();
while (iterator.hasNext()) {
Object next = iterator.next();
String name= next.getName();
List<Object> nameList= map.get(name);
if (nameList == null) {
nameList= new ArrayList<>();
}
nameList.add(next);
map.put(name, nameList);//分组数据
}