Here you can find the source of toArray(ArrayList
private static String[] toArray(ArrayList<String> sigs)
//package com.java2s; /******************************************************************************* * Copyright (c) 2002 - 2006 IBM Corporation. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w ww. j a v a 2s. c om * IBM Corporation - initial API and implementation *******************************************************************************/ import java.util.ArrayList; import java.util.Iterator; public class Main { private static String[] toArray(ArrayList<String> sigs) { int size = sigs.size(); if (size == 0) { return new String[0]; } Iterator<String> it = sigs.iterator(); String[] result = new String[size]; for (int j = 0; j < size; j++) { result[j] = it.next(); } return result; } }