I have a map Map<String, Set<String>>
Map<String, Set<String> result = map.entrySet().parallelStream().collect(
Collectors.groupingBy(Map.Entry::getValue, Collectors.mapping(Map.Entry::getKey, Collectors.toSet())));
I want to convert it to Map<String, Set<String>> . by grouping the values and swapping the places of key and value.
But this line gives me
Type mismatch: cannot convert from Map<Object,Set<Object>> to Map<String,Set<String>>
ObjecttoString.Map<Set<String>, Set<String>>, but declare theresultvariable with an entirely different type (and there’s a>missing). So it’s not surprising that you get a compiler error.Type mismatch: cannot convert from Map<Object,Set<Object>> to Map<String,Set<String>>is the crux of it? agreed though there is clutter in the question.