Here you can find the source of toList(Collection> collection)
public static List<Object> toList(Collection<?> collection)
//package com.java2s; /******************************************************************************* * Copyright (c) 2012 Tilera 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://from w ww.j a v a2 s. c o m * William R. Swanson (Tilera Corporation) *******************************************************************************/ import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { /** Creates list from array/set of elements */ public static List<Object> toList(Collection<?> collection) { int size = (collection == null) ? 0 : collection.size(); List<Object> result = new ArrayList<Object>(size); if (collection != null) result.addAll(collection); return result; } }