public class Food {
}
public class Fruit extends Food {
}
public class Apple extends Fruit {
}
ArrayList<? super Fruit> arrayList = new ArrayList<>();
arrayList.add(new Apple()); //
arrayList.add(new Fruit()); //
arrayList.add(new Food()); //
Why did I report an error?
the reason I have this problem is this:
static void set(Pair<? super Integer> p,Integer first,Integer last){
p.setFirst(first);
p.setLast(last);
}
public static void main(String[] args) {
PairHelp.set(new Pair<Integer>(1,2),1,2);
PairHelp.set(new Pair<Number>(1,2),1,2); //
}
what"s the difference between the two?