convert list of map to map using flatMap
问题 How I can merge List<Map<String,String>> to Map<String,String> using flatMap ? Here's what I've tried: final Map<String, String> result = response .stream() .collect(Collectors.toMap( s -> (String) s.get("key"), s -> (String) s.get("value"))); result .entrySet() .forEach(e -> System.out.println(e.getKey() + " -> " + e.getValue())); This does not work. 回答1: Assuming that there are no conflicting keys in the maps contained in your list, try following: Map<String, String> maps = list.stream()