package niu.cheng5;
import java.util.ArrayList;
import java.util.Collection;
/*
* 泛型高级通配符
* ?:
* ?extends E:
* ?super E:
*/
public class FanGao {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
/*
//泛型明确些的时候,前后必须一致
Collection<Object> c1=new ArrayList<Object>();
Collection<Object> c2=new ArrayList<Dong>();
Collection<Object> c3=new ArrayList<Dog>();
Collection<Object> c4=new ArrayList<Cat>();
*/
/*
//? 表示任意类型都是可以的
Collection<?> c1=new ArrayList<Object>();
Collection<?> c2=new ArrayList<Dong>();
Collection<?> c3=new ArrayList<Dog>();
Collection<?> c4=new ArrayList<Cat>();
*/
/*
// ?extends E:向下限定,限定E及其子类
Collection<? extends Dong > c1=new ArrayList<Object>();
Collection<? extends Dong> c2=new ArrayList<Dong>();
Collection<? extends Dong> c3=new ArrayList<Dog>();
Collection<? extends Dong> c4=new ArrayList<Cat>();
*/
/*
//?super E: 向上限定,限定E及其父类
Collection<? super Dong > c1=new ArrayList<Object>();
Collection<? super Dong> c2=new ArrayList<Dong>();
Collection<? super Dong> c3=new ArrayList<Dog>();
Collection<? super Dong> c4=new ArrayList<Cat>();
*/
}
}
class Dong{
}
class Dog extends Dong{
}
class Cat extends Dong{
}
import java.util.ArrayList;
import java.util.Collection;
/*
* 泛型高级通配符
* ?:
* ?extends E:
* ?super E:
*/
public class FanGao {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
/*
//泛型明确些的时候,前后必须一致
Collection<Object> c1=new ArrayList<Object>();
Collection<Object> c2=new ArrayList<Dong>();
Collection<Object> c3=new ArrayList<Dog>();
Collection<Object> c4=new ArrayList<Cat>();
*/
/*
//? 表示任意类型都是可以的
Collection<?> c1=new ArrayList<Object>();
Collection<?> c2=new ArrayList<Dong>();
Collection<?> c3=new ArrayList<Dog>();
Collection<?> c4=new ArrayList<Cat>();
*/
/*
// ?extends E:向下限定,限定E及其子类
Collection<? extends Dong > c1=new ArrayList<Object>();
Collection<? extends Dong> c2=new ArrayList<Dong>();
Collection<? extends Dong> c3=new ArrayList<Dog>();
Collection<? extends Dong> c4=new ArrayList<Cat>();
*/
/*
//?super E: 向上限定,限定E及其父类
Collection<? super Dong > c1=new ArrayList<Object>();
Collection<? super Dong> c2=new ArrayList<Dong>();
Collection<? super Dong> c3=new ArrayList<Dog>();
Collection<? super Dong> c4=new ArrayList<Cat>();
*/
}
}
class Dong{
}
class Dog extends Dong{
}
class Cat extends Dong{
}