I have an array of arrays of two strings.
var array = new String[][]{
{"a", "1"},
{"a", "2"},
{"b", "3"},
...
};
How can I collect the above array into a Map<String, Set<String>> whose key is the first element of each array and the value is a set of second elements of the array?
So that I get following map?
// Map<String, Set<String>>
<"a", ["1, "2"]>,
<"b", ["3"]>,
...
So far, I found I can classify the first element of each array like this.
Arrays.stream(array).collect(Collectors.groupingBy(
a -> ((String[])a)[0],
// how can I collect the downstream?
);