Java List from Array copyToList(T[] array)

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

Description

Copy the given array to a dynamic List .

License

Open Source License

Declaration

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

Method Source Code

//package com.java2s;
// it under the terms of the GNU Lesser General Public License as published by

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**/*from ww w  . j  a  va 2 s.c  om*/
     * Copy the given array to a dynamic {@link List}.
     */
    public static <T> List<T> copyToList(T[] array) {
        List<T> list = new ArrayList<T>(array.length);
        for (T elem : array) {
            list.add(elem);
        }
        return list;
    }
}

Related

  1. convertArrayToList(String[] arrayStr)
  2. convertArrayToList(T... objects)
  3. convertArrayToList(T[] array)
  4. convertArrayToList(T[] arrayOfObjects)
  5. copyToList(T... items)