I have HashMap<String, ArrayList<String>> professions, and I want to create a SortedMap<String, Integer> where the first entry is a string same to the first entry of the hashmap, and second entry is an Integer equal to the size of the ArrayList in the first map corresponding to the string. I also want that the sortedMap is sorted by the first entry (the string).
I tryed the following:
professions.entrySet().stream()
.collect(Collectors.groupingBy(e -> e.getKey(), TreeMap::new,
Collectors.mapping(e -> e.getValue().size()));
Eclipse tells me The method mapping(Function<? super T,? extends U>, Collector<? super U,A,R>) in the type Collectors is not applicable for the arguments ((<no type> e) -> {}) and also The method getValue() is undefined for the type T.
I'm not sure if my solution is wrong at all, or it's just eclipse that can't infer type.