特定Java通用数组创建
Possible Duplicate:
Java 1.6: Creating an array of List<T>
如何用Java初始化这个数组
Vector<Integer>[] c;
我已经试过了:
Vector<Vector<Integer>[]> a = new Vector<Vector<Integer>[]>();
Vector<Integer>[] c = (Vector<Integer>[])a.toArray();
出现以下错误:
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.util.Vector; at app.Program.main(Program.java:38) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
编辑:
我的问题是,我是一个类的客户端,该类接收一个泛型数组“T[]args”参数,在我的例子中,T是一个泛型类型,比如向量,谢谢
我是Java新手
共 (0) 个答案