Java List Create createList(T... element)

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

Description

Creates a new list and adds the element(s).

License

sencha.com license

Parameter

Parameter Description
element the item to add to the list

Return

the new list

Declaration

public static <T> List<T> createList(T... element) 

Method Source Code

//package com.java2s;
/**// ww w .j  av  a  2 s  . co  m
 * Sencha GXT 3.0.1 - Sencha for GWT
 * Copyright(c) 2007-2012, Sencha, Inc.
 * licensing@sencha.com
 *
 * http://www.sencha.com/products/gxt/license/
 */

import java.util.ArrayList;
import java.util.List;

public class Main {
    /**
     * Creates a new list and adds the element(s).
     * 
     * @param element the item to add to the list
     * @return the new list
     */
    public static <T> List<T> createList(T... element) {
        List<T> list = new ArrayList<T>();
        fill(list, element);
        return list;
    }

    /**
     * Populates a list with an array of elements.
     * 
     * @param list the list
     * @param elements the elements to be added to the list
     */
    public static <T> void fill(List<T> list, T[] elements) {
        for (int i = 0; i < elements.length; i++) {
            list.add(elements[i]);
        }
    }
}

Related

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