例如:(1)public class ArrayList <E>
(2)public class HashMap<K,V>
(3)public interface Collection<E>
使用泛型要求传给泛型类或泛型接口的类型必须是引用数据类型,不能是基本数据类型;
如何向泛型类或泛型接口指定实参类型?
(1)创建对象:ArrayList< String > arrayList = new ArrayList< String >();
(2)子类继承泛型类:泛型类: public class GenerClass<T>
子类: public class ExtendsGenerClass extends GenerClass<String>
(3)实现泛型接口:public class ImplementsGenerInterface implements Comparable<String>