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
Tag: covariance
java generics covariance
I am having trouble understanding the following article: http://www.ibm.com/developerworks/java/library/j-jtp01255.html Under, Generics are not covariant the author states, Because ln is a List, adding a Float to it seems perfectly legal. But if ln were aliased with li, then it would break the type-safety promise implicit in the definition of li — that it is a list of integers, which is