Skip to content

timp21337/java-generics-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Casting to a superclass collection of superclassed items not allowed in Java.
The reason is that the type you cast to could then have added to it a third type, 
which also subclassed the supertype but not the original items.

http://stackoverflow.com/questions/9832396/why-is-casting-a-sub-classed-collection-of-subclassed-objects-to-its-superclass
http://en.wikipedia.org/wiki/Covariance_and_contravariance_%28computer_science%29%3E