Here you can find the source of toArray(List list, Object array[], int start, int end)
public static Object[] toArray(List list, Object array[], int start, int end)
//package com.java2s; /*// w w w . j a v a2 s . c om Strandz LGPL - an API that matches the user to the data. Copyright (C) 2007 Chris Murphy Strandz LGPL is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA The authors can be contacted via www.strandz.org */ import java.util.List; public class Main { public static Object[] toArray(List list, Object array[], int start, int end) { return toArray(list, array, start, end, -1); } /** * Similar to ArrayList.toArray(), but this method will return a range * from the passed in list * * @param list * @param array */ public static Object[] toArray(List list, Object array[], int start, int end, int skip) { Object[] result = array; int j = 0; for (int i = start; i <= end; i++, j++) { Object o = null; if (skip == -1 || i != skip) { o = list.get(i); } result[j] = o; } //Print.prArray( result, "toArray() result"); return result; } /** * Similar to ArrayList.toArray(), but this method will return a range * from the passed in list * * @param list */ public static Object[] toArray(List list, int start, int end) { int sizeOfResult = start - end + 1; Object[] result = toArray(list, new Object[sizeOfResult], start, end); return result; } }