Here you can find the source of createList(final T... elements)
Parameter | Description |
---|---|
T | The type of the elements and the list. |
elements | The elements to add to the list. |
public static <T> List<T> createList(final T... elements)
//package com.java2s; //License from project: BSD License import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { /**/* w w w. j av a 2s . co m*/ * Creates a list of the given type for the given elements. * * @param <T> * The type of the elements and the list. * @param elements * The elements to add to the list. * @return The filled list. */ public static <T> List<T> createList(final T... elements) { if (elements == null) { return new ArrayList<T>(); } else { return new ArrayList<T>(Arrays.asList(elements)); } } }