I have the following code, which makes use of the collector groupingBy()
Stream<String> stream = Stream.of("lions", "tigers", "bears", "toads", "tarantullas");
Map<Integer, ?> map7 = stream.collect(
Collectors.groupingBy(
String::length,
Collectors.mapping(s -> s.charAt(0),
Collectors.toList()
)
));
System.out.println("map7: " + map7);
System.out.println("value type: " + map7.get(5).getClass());
Output:
map7: {5=[l, b, t], 6=[t], 11=[t]}
value type: java.util.ArrayList
How can I sort letters in each list, and what should be the appropriate type of map's value?