HashMap<String, ArrayList<? extends Serializable>> map = new HashMap<String, ArrayList<ArrayList>>();
This does not compile. To the best of my knowledge on Java Generics, it should. And this:
ArrayList<? extends Serializable> c = new ArrayList<ArrayList<String>>();
successfully compiles.
Can anyone say why the above wouldn't compile?
ArrayList<String>doesn't extendSerializable?Aextends (or implements)Bdoesn't imply thatHashMap<K,A>extendsHashMap<K,B>. After all, aHashMap<K,B>is something that you can put aBin, but aHashMap<K,A>isn't. Equivalent questions have been asked before.