Here you can find the source of arrayToArrayList(T[] array)
Parameter | Description |
---|---|
array | The array to convert to an ArrayList . |
public static <T> ArrayList<T> arrayToArrayList(T[] array)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { /**/*from w w w . j a v a2 s . c om*/ * Converts a Java array to an {@link ArrayList}. * * @param array The array to convert to an {@link ArrayList}. * * @return An {@link ArrayList} containing all elements of the given array. */ public static <T> ArrayList<T> arrayToArrayList(T[] array) { if (array == null) throw new IllegalArgumentException("Parameter 'array' cannot be null!"); ArrayList<T> arrayList = new ArrayList<T>(); for (T element : array) arrayList.add(element); return arrayList; } }