Why is List not a subtype of List? [duplicate]

List<String> s = new ArrayList<String>();
List<Object> o = s;
o.add(new Object());
String first = s.get(0);  // boom

Leave a Comment