Collection<? super String>
, counter to your intuition, does not mean "a collection which contains objects of type String
or its supertype". It means "col
will be a collection holding some definite type, which itself is String
or its supertype" (such as Object
, Serializable
, or CharSequence
).
The best way to think about Collection<? super String>
is that it is not a type, like you are used to in Java, but a pattern against which specific types are matched.
Now, the only thing you can safely add to any collection which matches the above pattern is a String
or its subclass (if there were any). Quite the opposite of what you would have expected, isn't it? That's Generics for you.