Let’s say we have some interface like this: I’m using Foo a lot in my codebase, but I wish to add the TIn extends T to make it more flexible, to eg have a Foo<Map<X>> able to encode a HashMap<X> or a TreeMap<X>. This works really well – until I tried to implement Foo<T[]>, where it seems to be impossible
Tag: contravariance
Covariance, Invariance and Contravariance explained in plain English?
Today, I read some articles about Covariance, Contravariance (and Invariance) in Java. I read the English and German Wikipedia article, and some other blog posts and articles from IBM. But I’m still a little bit confused on what these exactly are about? Some say it’s about relationship between types and subtypes, some say it’s about type conversion and some say