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

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

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

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

		List> 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())));
		
	}

你可能感兴趣的:(JAVA后端)