Content deleted Content added
rewrite/expand |
→Covariance for generic types: correct mistake |
||
Line 5:
Unlike arrays (which are [[Covariance and contravariance (computer science)#Covariant arrays in Java and C#|covariant]] in Java), different instantiations of a generic type are not compatible with each other, not even explicitly: With the declaration <code>Generic<Supertype> superGeneric; Generic<Subtype> subGeneric;</code> the compiler would report a conversion error for both castings <code>(Generic<Subtype>)superGeneric</code> and <code>(Generic<Supertype>)subGeneric</code>.
This incompatibility may be softened by the wildcard if <code>?</code> is used as an actual type parameter: <code>Generic<?></code> is the abstract supertype for all
== Wildcard as parameter type ==
|