Here you can find the source of asArrayList(Collection c)
public static ArrayList asArrayList(Collection c)
//package com.java2s; import java.util.ArrayList; import java.util.Collection; public class Main { public static ArrayList asArrayList(Collection c) { return (ArrayList) asTargetTypeCollection(c, ArrayList.class); }// w ww . j a v a 2 s . c om public static Collection asTargetTypeCollection(Collection c, Class targetCollectionClass) { if (targetCollectionClass == null) throw new IllegalArgumentException("'targetCollectionClass' must be not null"); if (c == null) return null; if (targetCollectionClass.isInstance(c)) return c; Collection result = null; try { result = (Collection) targetCollectionClass.newInstance(); } catch (Exception e) { throw new IllegalArgumentException( "targetCollectionClass=" + targetCollectionClass.getName() + " is not correct!", e); } result.addAll(c); return result; } }