Issue with declaration of Map<String,Class<? extends Serializable>>
Java provides me by <? extends class> a way of filtering the java classes that you can use to build in this case the new HashMap, for example: I can do that: Map<String,? extends Serializable> map1 = new HashMap<String,String>(); It is correct, because String implements Serializable, so the compiler let me do that. But when i try to do it: Map<String,GenericClass<? extends Serializable>> map2 = new HashMap<String, GenericClass<String>>(); Being the GenericClass as it: public class GenericClass<T> { . . . } The compiler throw an error saying: Type mismatch: cannot convert from HashMap<String