Here you can find the source of newList(T... elements)
Parameter | Description |
---|---|
elements | elements to be contained in the list. |
T | type of list elements |
@SafeVarargs public static <T> List<T> newList(T... elements)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { /**//from w w w .j a v a2 s. c om * Create {@link ArrayList} with some elements contained. * * @param elements * elements to be contained in the list. * @param <T> * type of list elements * @return list */ @SafeVarargs public static <T> List<T> newList(T... elements) { ArrayList<T> result = new ArrayList<>(); for (T element : elements) { result.add(element); } return result; } }