Android Collection to ArrayList Convert asArrayList(Collection collection)

Here you can find the source of asArrayList(Collection collection)

Description

Takes any collection and turns it into an java.util.ArrayList

Parameter

Parameter Description
collection a parameter
E < >

Declaration

public static <E> ArrayList<E> asArrayList(Collection<E> collection) 

Method Source Code

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

public class Main {
    /**/*w  w  w .j  a v  a 2  s . co  m*/
     * Takes any collection and turns it into an {@link java.util.ArrayList}
     * @param collection
     * @param <E>
     * @return
     */
    public static <E> ArrayList<E> asArrayList(Collection<E> collection) {
        ArrayList<E> arrayList = new ArrayList<>();
        arrayList.addAll(collection);
        return arrayList;
    }
}