I was reading Thinking in Java 4th edition, and in the Chapter Generics, I found these sentences: This paragraph is explaining why array support covariance but generics don't.
The real issue is that we are talking about the type of the container, rather than the type that the container is holding. Unlike arrays, generics do not have built-in covariance. This is because arrays are completely defined in the language and can thus have both compile-time and run-time checks built in,but with generics, the compiler and runtime system cannot know what you want to do with your types and what the rules should be.
but I cannot really understand what this paragraph means, why the compiler know what you want to do with arrays but cannot know what you want to do with generics? can anybody give me any example?