汎用ワイルドカード?の使用


package cn.itcast.day16.generic;

import java.util.ArrayList;
import java.util.Collection;
/*
 *  ( )
 * ?:
 * ? extends E:  ? E 
 * ? super E:   ? E 
 */
public class GenericDemo {
    public static void main(String[] args) {
        //
        Collection<Object> c=new ArrayList<Object>();
        Collection<Animal> c1=new ArrayList<Animal>();
//        Collection<Animal> c2=new ArrayList<Dog>();
//        Collection<Animal> c3=new ArrayList<Cat>();
        
        //? extends E:  ? E 
//        Collection <? extends Animal> c4=new ArrayList<Object>();
        Collection <? extends Animal> c5 = new ArrayList<Animal>();
        Collection<? extends Animal> c6 = new ArrayList<Dog>();
        Collection<? extends Animal> c7 =new ArrayList<Cat>();
        
        
        // ? super E:   ? E 
        Collection<? super Animal> c8=new ArrayList<Object>();
        Collection<? super Animal> c9=new ArrayList<Animal>();
//        Collection<? super Animal> c10=new ArrayList<Dog>();
//        Collection<? super Animal> c11=new ArrayList<Cat>();
        
        
    }

}

class Animal{
    
}
class Dog extends Animal{
}
class Cat extends Animal{
}