parent: Fruit
subclass: Apple
List < Fruit > fruitList = new ArrayList < Fruit > ();
fruitList.add (new Apple ()); is OK, but I don"t want Apple to fit in
so create a function
public static < T > void add (List < T > list,T item) {
list.add(item);
}
result add (fruitList,new Apple ()); can still be put in
however, "java programming ideas" should not be put into
.
I"m confused. Has the mechanism in the book been removed?