将两个ListMap中同下标的map去重合并

public static void main(String[] args) {
        
        Map<String,Object> oneMap = new HashMap<>();
        oneMap.put("key","001");
        oneMap.put("name","张飞");
        oneMap.put("age","25");

        Map<String,Object> twoMap = new HashMap<>();
        twoMap.put("key","001");
        twoMap.put("School","桃园");
        twoMap.put("age","25");

        List<Map<String,Object>> listA = new ArrayList<>();
        listA.add(0,oneMap);

        List<Map<String,Object>> listB = new ArrayList<>();
        listB.add(0,twoMap);

        listA.forEach(a -> {
            listB.forEach(b -> b.putAll(a));
        });

        listB.forEach(b -> b.entrySet().forEach(e -> System.out.println(e.getValue())));
        
    }

 

posted @ 2020-09-02 17:14  红尘沙漏  阅读(1154)  评论(0编辑  收藏  举报