[笔迹]java范型

泛型类

public class classname<type1, type2...>{

}

classname n = new classname<String, Integer>();

泛型接口

public interface interfacename<type1, type2>{}

泛型方法

public <T> void functionname(T t){

}

泛型数组

List<T> array = new ArrayList<T>();

通配符

List<object> list = new ArrayList<classname>;//error

List<? extends xxx> list= new ArrayList<classextendsxxx>; //无法编译

超类通配符

<? super MyClass>

数组和泛型不能一起使用

classname<type>[] t = new classname<type>[10]; //error

原文地址:https://www.cnblogs.com/zengyou/p/2773371.html