62,614
社区成员
发帖
与我相关
我的任务
分享
public <T> T[] toArray(Class<T> clazz) {
//if (a.length < size)
T[] a = (T[])java.lang.reflect.Array.newInstance(clazz, size);
System.arraycopy(elementData, 0, a, 0, size);
return a;
}
public <T> T[] toArray(T[] a) {
if (a.length < size)
a = (T[])java.lang.reflect.Array.
newInstance(a.getClass().getComponentType(), size);
System.arraycopy(elementData, 0, a, 0, size);
if (a.length > size)
a[size] = null;
return a;
}