Java 8 List into Map

Based on Collectors documentation it’s as simple as:

Map<String, Choice> result =
    choices.stream().collect(Collectors.toMap(Choice::getName,
                                              Function.identity()));

Leave a Comment