Java ArrayList Create asArrayList(Collection list)

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

Description

as Array List

License

Open Source License

Declaration

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

Method Source Code


//package com.java2s;
/*//from w w w. jav  a  2s.c  om
 * Carrot2 project.
 *
 * Copyright (C) 2002-2016, Dawid Weiss, Stanis?aw Osi?ski.
 * All rights reserved.
 *
 * Refer to the full license file "carrot2.LICENSE"
 * in the root folder of the repository checkout or at:
 * http://www.carrot2.org/carrot2.LICENSE
 */

import java.util.*;

public class Main {
    public static <E> ArrayList<E> asArrayList(Collection<E> list) {
        if (ArrayList.class.isInstance(list)) {
            return (ArrayList<E>) list;
        } else {
            return new ArrayList<E>(list);
        }
    }
}

Related

  1. asArrayList(Collection collection)
  2. createArrayList()
  3. createArrayList()
  4. createArrayList(Collection arg)