Add subclasses to ConcurrentHashMap of super type in a static initializer?
问题 public class People { class Family extends People { } } public class Together { private static Collection<Family> familyList = new ArrayList<Family>(); private static ConcurrentMap<String, Collection<People>> registry = new ConcurrentHashMap<String, Collection<People>>(); static { registry.put(Family.class.toString(), familyList); } } Error message: The method put(String, Collection<people>) in the type Map<String,Collection<people>> is not applicable for the arguments (String, Collection