【发布时间】:2011-02-09 12:17:17
【问题描述】:
在这种情况下,最佳做法是什么?我想要一个类型和长度与原始数组相同的未初始化数组。
public static <AnyType extends Comparable<? super AnyType>> void someFunction(AnyType[] someArray) {
AnyType[] anotherArray = (AnyType[]) new Comparable[someArray.length];
...or...
AnyType[] anotherArray = (AnyType[]) new Object[someArray.length];
...some other code...
}
谢谢, CB
【问题讨论】:
-
为什么这个标签是“初学者”?