A simple question about Class and its generic semantics. Why doesn’t the following code work?
Class<Serializable> s = String.class;
Java tells me that Class<Serializable> and Class<String> are incompatible. How can they be, when String is implementing Serializable?
Shouldn’t generics allow exactly this type of things?
because
Class<String>is notClass<Serializable>. HoweverClass<String>isClass<? extends Serializable>