Skip to main content

Command Palette

Search for a command to run...

Convert List of hashmap to map using streams

Updated
1 min read
Convert List of hashmap to map using streams
S

I love learning about technology and sharing that with others


    private static Map<String, String> convertListOfHashMap_UsingStream(List<Map<String, String>> input) {
        return input.stream().collect(Collectors.toMap(i -> i.get("attribute_name"), i -> i.get("value")));
    }

    private static Map<String, String> convertListOfHashMap_UsingParallelStream(List<Map<String, String>> input) {
        return input.parallelStream().collect(Collectors.toConcurrentMap(i -> i.get("attribute_name"), i -> i.get("value")));
    }

More from this blog

H

hashcodehub

271 posts

Consistent, Passionate and Organized :)