How do I convert a List<Entry> to Map<Entry::getKey, List<Entry::getValue>> using streams in Java 8?
I couldn't come up with a good KeySelector for Collectors.toMap():
List<Entry<Integer, String>> list = Arrays.asList(Entry.newEntry(1, "a"), Entry.newEntry(2, "b"), Entry.newEntry(1, "c"));
Map<Integer, List<String>> map = list.stream().collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
What I want to get: {'1': ["a", "c"], '2': ["b"]}.
List?11and the value of["a", "c"]. What I'm talking about would be something like{'1': ["a", "c"], '1': ["x", "z"] ... }