Created
June 14, 2022 13:09
-
-
Save akarnokd/75e4604c2c25d135c45969bccf3bf54a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Map<List<String>, String> map = new HashMap<>(); | |
map.put(List.of("A", "B"), "X"); | |
map.put(List.of("C"), "Y"); | |
var result = map.entrySet() | |
.stream() | |
.flatMap(kv -> kv.getKey().stream().map(k -> Map.entry(k, kv.getValue()))) | |
.collect(Collectors.toMap(k -> k.getKey(), v -> v.getValue())); | |
result.entrySet().forEach(System.out::println); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment