Here you can find the source of asArrayList(Collection
public static <E> ArrayList<E> asArrayList(Collection<E> list)
//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); } } }