Java Array to List newList(T... values)

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

Description

A fast and easy way to build a list.It delegates to Arrays#asList(Object) .

License

Apache License

Parameter

Parameter Description
T The set elements type.
values The set elements.

Return

The newly constructed hash set.

Declaration

public static <T> List<T> newList(T... values) 

Method Source Code

//package com.java2s;
/*//from w w w . j ava2s  . com
 * Entwined STM
 * 
 * (c) Copyright 2013 CERN. This software is distributed under the terms of the Apache License Version 2.0, copied
 * verbatim in the file "COPYING". In applying this licence, CERN does not waive the privileges and immunities granted
 * to it by virtue of its status as an Intergovernmental Organization or submit itself to any jurisdiction.
 */

import java.util.ArrayList;
import java.util.Arrays;

import java.util.List;

public class Main {
    /**
     * A fast and easy way to build a list.It delegates to {@link Arrays#asList(Object...)}.
     * 
     * @param <T> The set elements type.
     * @param values The set elements.
     * @return The newly constructed hash set.
     */
    public static <T> List<T> newList(T... values) {
        if (null == values) {
            return new ArrayList<T>();
        } else {
            return new ArrayList<T>(Arrays.asList(values));
        }
    }
}

Related

  1. newList(T... items)
  2. newList(T... list)
  3. newList(T... objects)
  4. newList(T... objs)
  5. newList(T... ts)
  6. newList(V... items)
  7. toList(@SuppressWarnings("unchecked") T... ts)
  8. toList(boolean... booleans)
  9. toList(boolean[] array)