
/**
* 使用有限制的通配符“? extends”,可以接受任何Parent及其子类的Collection
* @param collect
*/
public static void printNames(Collection<? extends Parent> collect){
if (collect == null){
return;
}
for(Parent parent : collect){
System.out.print(parent.name + " ");
}
System.out.println();
}



中级程序员
by: 中国人在美国 发表于:2013-08-01 05:35:51 顶(1) | 踩(0) 回复
如果有Parent的定义的话对初学者更容易理解一些
回复评论