Here you can find the source of array2ArrayList(final T[] array)
Parameter | Description |
---|---|
T | The type held in the array |
array | The array of values |
public static <T> ArrayList<T> array2ArrayList(final T[] array)
//package com.java2s; /*/*w ww . ja va2 s .c o m*/ * oxCore is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. * * Copyright (c) 2014, Gluu */ import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { /** * Converts an array to the appropriate ArrayList * * @param <T> * The type held in the array * @param array * The array of values * @return An ArrayList<T> of the same values * */ public static <T> ArrayList<T> array2ArrayList(final T[] array) { if ((array == null) || (array.length == 0)) { return new ArrayList<T>(); } final List<T> list = Arrays.asList(array); return new ArrayList<T>(list); } }