【发布时间】:2011-08-11 10:45:33
【问题描述】:
为什么我们做不到
List<Parent> mylist = ArrayList<child>();
【问题讨论】:
-
Nitpick:
Parent/Child比喻在讨论继承时很奇怪,因为继承描述了 is a 关系。 (你会说Child是Parent吗?) -
因为家族树或层次结构经常被用作 Java 类型层次结构的类比。虽然从语义上讲你有道理。
标签: java generics inheritance collections