Java Array to List newList(final T... elements)

Here you can find the source of newList(final T... elements)

Description

new List

License

Open Source License

Declaration

@SafeVarargs
    public static <T> List<T> newList(final T... elements) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2015 Vienna University of Technology.
 * 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 w  w.  j av  a  2s .co  m*/
 * Martin Fleck (Vienna University of Technology) - initial API and implementation
 *
 * Initially developed in the context of ARTIST EU project www.artist-project.eu
 *******************************************************************************/

import java.util.ArrayList;

import java.util.List;

public class Main {
    @SafeVarargs
    public static <T> List<T> newList(final T... elements) {
        final ArrayList<T> list = new ArrayList<>();
        for (final T element : elements) {
            list.add(element);
        }
        return list;
    }
}

Related

  1. fromArray(T array[])
  2. fromArray(T... array)
  3. fromArray(T[] array, Class clazz)
  4. fromArray(T[] objects)
  5. newList(final T... elements)
  6. newList(int... sizes)
  7. newList(T... elements)
  8. newList(T... elements)
  9. newList(T... items)