private Map<String, List<A>> getMap(List<A> a,List<B> b)
throws SQLException {
Map<String,List<A>> retmap = new HashMap<String,List<A>>();
Map midMap1 = new HashedMap();
for (A obj : a) {
midMap1.put("K_"+obj.getId(), obj);
}
for (B obj : b) {
if(midMap1.get("K_"+obj.getId())!=null)
{
if(retmap.get(""+obj.getType()) ==null)
{
retmap.put( ""+obj.getType(), new ArrayList());
}
List ls = (ArrayList)retmap.get(""+obj.getType());
ls.add(midMap1.get("K_"+obj.getId())) ;
retmap.put(""+obj.getType(), ls);
}
}
return retmap;
}
遍历List 按照类型分类组装map对象
最新推荐文章于 2022-05-18 22:16:57 发布