Java List from Array arrayToList(T[] array)

Here you can find the source of arrayToList(T[] array)

Description

Array to List converter

License

GNU General Public License

Parameter

Parameter Description
T []

Return

List

Declaration

public static <T> List<T> arrayToList(T[] array) 

Method Source Code

//package com.java2s;
/*/* w ww . j  ava 2s .c  o m*/
 Pulsar
 Copyright (C) 2013-2015 eBay Software Foundation
 Licensed under the GPL v2 license.  See LICENSE for full terms.
 */

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**
     * Array to List converter
     * 
     * @param T
     *          []
     * @return List<T>
     */
    public static <T> List<T> arrayToList(T[] array) {
        List<T> list = new ArrayList<T>(); // we return at least empty list for EPL
        if (array != null) {
            for (T element : array) {
                list.add(element); // we don't filter null out
            }
        }
        return list;
    }
}

Related

  1. ArrayToList(String[] input)
  2. arrayToList(String[] str)
  3. arrayToList(T array[])
  4. arrayToList(T[] array)
  5. arrayToList(T[] array)
  6. arrayToList(T[] array)
  7. arrayToList(T[] array)
  8. arrayToList(T[] obj, List newList)
  9. arrayToList(T[] source)