某些场景需要⼀个key值下⾯对应多个值,但是map的⼀个key值只对应⼀个value值,由于hashmap相同的key值,第⼆个put进去会覆盖第⼀个的值,所以为了解决这⼀问题:所以⽤list存 如下:
List<Map<String, List<RecommendationListBO>>> hashList = new ArrayList<>();
Iterator<Map.Entry<String, List<RecommendationListBO>>> iterator = Set().iterator();
Map.Entry<String, List<RecommendationListBO>> entry;
while (iterator.hasNext()) {
entry = ();
// 往newMap中放⼊新的Entry
HashMap<String, List<RecommendationListBO>> newMap = new LinkedHashMap<>();
newMap.Key().split(",")[0], Value());
hashList.add(newMap);
}
每次new⼀个新的map,add到map的list⾥⾯。思路⼤概是这样的。