Java泛型认识与总结之一(超好)
打开jdk1.6源码,看到这个片段:
public interface List<E> extends Collection<E> {
??????? Iterator<E> iterator();
??????? boolean containsAll(Collection<?> c);
}
其中用尖括号括起来的就是泛型,因此我们可以像这样的使用:
List<Integer> intList = new ArrayList<Integer>();
List<String> strList = new ArrayList<String>();
?