import java.util.ArrayList;
import java.util.List;//泛型通配符的使用
public class test73 {public static void main(String[] args){List<Integer> intList=new ArrayList<Integer>();intList.add(new Integer(100));intList.add(new Integer(200));List<?> list=intList;System.out.println("第一次大小"+list.size());for(Object Obj:list) {System.out.println(((Integer)Obj).intValue());}List<Number> numList=new ArrayList<Number>();numList.add(new Double(6.66));numList.add(new Double(7.66));numList.add(new Double(666.6));list=numList;System.out.println("第二次大小"+list.size());for(Object obj:list){System.out.println(((Number)obj).doubleValue());}}
}
运行结果