Java Array to ArrayList toArrayList(final T... array)

Here you can find the source of toArrayList(final T... array)

Description

to Array List

License

Open Source License

Parameter

Parameter Description
array A collection of elements to be included in the returned ArrayList

Return

An ArrayList that includes all the elements passed in via the array parameter

Declaration

public static <T> ArrayList<T> toArrayList(final T... array) 

Method Source Code


//package com.java2s;
import java.util.ArrayList;

import java.util.Collection;

public class Main {
    /**/*w w  w. j  av  a 2  s.  c  o  m*/
     * @param array A collection of elements to be included in the returned ArrayList
     * @return An ArrayList that includes all the elements passed in via the array parameter
     */
    public static <T> ArrayList<T> toArrayList(final T... array) {
        final ArrayList<T> retValue = new ArrayList<T>();
        for (final T item : array)
            retValue.add(item);
        return retValue;
    }

    /**
     * @param items The Collection of items to be converted to an ArrayList
     * @return An ArrayList containing the elements in the set
     */
    public static <T> ArrayList<T> toArrayList(final Collection<T> items) {
        final ArrayList<T> retValue = new ArrayList<T>();
        for (final T item : items)
            retValue.add(item);
        return retValue;
    }
}

Related

  1. byteArrayToShortArrayList(byte[] byteArray)
  2. toArrayList( Iterable iterable)
  3. toArrayList(Collection collection)
  4. toArrayList(Collection from)
  5. toArrayList(double[] dd)
  6. toArrayList(int[] p)
  7. toArrayList(int[] values)
  8. toArrayList(List list)
  9. toArrayList(Object pObject)