Java List Create createList(T... _entries)

Here you can find the source of createList(T... _entries)

Description

Creates a list from a varargs parameter array.

License

Open Source License

Parameter

Parameter Description
_entries list entries
T list type

Return

list

Declaration

@SafeVarargs
public static <T> List<T> createList(T... _entries) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

import java.util.List;

public class Main {
    /**//  w ww.j av  a  2  s  .c om
     * Creates a list from a varargs parameter array.
     * The generic list is created with the same type as the parameters.
     * @param _entries list entries
     * @param <T> list type
     * @return list
     */
    @SafeVarargs
    public static <T> List<T> createList(T... _entries) {
        List<T> l = new ArrayList<>();
        if (_entries != null) {
            l.addAll(Arrays.asList(_entries));
        }
        return l;
    }
}

Related

  1. createList(Object... entries)
  2. createList(Object... objs)
  3. createList(Object[] values)
  4. createList(String s)
  5. createList(T value, int n)
  6. createList(T... array)
  7. createList(T... element)
  8. createList(T... items)
  9. createList(T... items)