Here you can find the source of listToArray(List
public static <T> T[] listToArray(List<T> list)
//package com.java2s; /******************************************************************************* * Copyright (c) 2012 IBM Corporation and others. * 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:/*ww w . ja v a2s . co m*/ * IBM Corporation - initial API and implementation *******************************************************************************/ import java.util.List; public class Main { public static <T> T[] listToArray(List<T> list) { @SuppressWarnings("unchecked") T[] array = (T[]) new Object[list.size()]; for (int i = 0; i < list.size(); i++) { T f = list.get(i); array[i] = (f != null ? f : null); // Or whatever default you want. } return array; } }