使用泛型列表创建类型特定列表
import java.net.MalformedURLException; import java.net.URL;// from N o w J a v a . c o m import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] args) throws Exception { List<Integer> intlist = new ArrayList<Integer>(); intlist.add(new Integer(123)); List<Number> numlist = new ArrayList<Number>(); numlist.add(new Integer(123)); numlist.add(new Float(123)); intlist.add(null); List<URL> urlList = new ArrayList<URL>(); try {//时 代 J a v a - nowjava.com urlList.add(