以下代码来自Arrays类:
http://developer.classpath.org/doc/java/util/Arrays-source.html
public static <T,U> T[] copyOfRange(U[] original, int from, int to,
Class<? extends T[]> newType)
{
if (from > to)
throw new IllegalArgumentException("The initial index is after " +
"the final index.");
T[] newArray = (T[]) Array.newInstance(newType.getComponentType(),
to - from);
if (to > original.length)
{
System.arraycopy(original, from, newArray, 0,
original.length - from);
fill(newArray, original.length, newArray.length, null);
}
else
System.arraycopy(original, from, newArray, 0, to - from);
return newArray;
}
我对Class<? extends T[]>部分感到困惑,如何T[]扩展?据我所知,没有这样的数组是K[]eventhough 的子类型。T[]K extends T