Possible Duplicate:
Java Generics: Cannot cast List<SubClass> to List<SuperClass>?
I'm just wondering why the following java code doesn't compile:
List<Object> c1 = new ArrayList<String>();
The error is:
cannot convert from ArrayList <String> to List<Object>
String extends Object, so I would have thought that with polymorphism, as String "is a" Object that the String could be substituted for Object.
I'm just starting to learn java so hopefully this question makes sense.
thanks in advance...