81,123
社区成员




public class Test<T>(){
public Test(){
T[]= new T[10];//这是错误的.要怎么样才能够实例化了?
T[]=???;
}
}
List<T> list = new ArrayList<T>();
//这个泛型T数组必须被实例化,不然下面的toArray会出现NullPointException,所以怎么样才能够将泛型数组实例化
T [] t =null;
t = list.toArray(t);
T[]t = new T[10];
public class TestArray {
public static void main(String[] args) {
String[] strings = {
"a", "b", "c"
};
Object[] objs = strings;
objs[0] = new Integer(1);
}
}
T[] ts =(T[]) new Object[10];