Java List from Array arrayToList(T[] array)

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

Description

Converts the generic array into an ArrayList of the same type.

License

Open Source License

Parameter

Parameter Description
array a parameter

Return

array list version

Declaration

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

Method Source Code

//package com.java2s;

import java.util.ArrayList;

public class Main {
    /**/*from  ww w . j  a v  a 2 s.  c om*/
     * Converts the generic array into an {@link ArrayList} of the same type.
     * 
     * @param array
     * @return array list version
     */
    public static <T> ArrayList<T> arrayToList(T[] array) {
        ArrayList<T> list = new ArrayList<T>(array.length);
        for (T element : array) {
            list.add(element);
        }
        return list;
    }
}

Related

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