Java Collection to List toList(Collection collection)

Here you can find the source of toList(Collection collection)

Description

Creates list from array/set of elements

License

Open Source License

Declaration

public static List<Object> toList(Collection<?> collection) 

Method Source Code

//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;
    }
}

Related

  1. newList(final Collection elements)
  2. newList(final Collection collection)
  3. newList(final Collection objects)
  4. toList(Collection addresses, char separator)
  5. toList(Collection collection)
  6. toList(Collection c)
  7. toList(Collection collection)
  8. toList(Collection lines)
  9. toList(Collection c)