Long[] l = new Long[<total size>]; list.toArray(l);
2.
Long[] l = (Long[]) list.toArray(new Long[0]);
3.
Long[] a = new Long[<total size>]; Long[] l = (Long[]) list.toArray(a); -----------------------------------------------------------------
java sdk doc 上讲:
public Object[] toArray(Object[] a) a--the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose. 如果这个数组a足够大,就会把数据全放进去,返回的数组也是指向这个数组;要是不够大,就申请一个跟参数同样类型的数组,把值放进去,然后返回。