package Test2016; import java.util.ArrayList; import java.util.List; public class Test2016 { public static void main(String[] args) { List<? super Fruit> first = new ArrayList<Fruit>(); //Fruit -> Apple first.add(new Apple()); first.add(new Fruit()); first.add(new RedApple()); // first.add(new Food()); //error System.out.println(first.get(0)); System.out.println(first.get(1)); List<? extends Apple> second = new ArrayList<Apple>(); second.add(null); } } class Food { } class Fruit extends Food { } class Apple extends Fruit { } class RedApple extends Apple { }