通过获取输入列表并向列表中添加元素来创建列表。
/** 时 代 J a v a - nowjava.com **/ //package com.nowjava; import java.util.ArrayList; import java.util.List; public class Main { /** * Creates a list by taking an input list and adding elements to the list. * * @param <T> Type of the list. * @param list The input list. * @param elems The elements to add to the list. * * @return The modified input list. */ public static <T> List<T> list(final List<T> list, final T... elems) { for (final T elem : elems) { list.add(elem); } return list; }// 来 自 时 代 Java - nowjava.com /** * Creates a list from a number of elements. * * @param <T> The type of the elements. * @param elems The elements to add to the list. * * @return The list that contains the input elements. */ public static <T> List<T> list(final T... elems) { final