Here you can find the source of toList(Collection
public static <E extends Object> List<E> toList(Collection<E> c)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { public static <E extends Object> List<E> toList(E[] e) { if (e == null) return new ArrayList<E>(0); // TODO temp ArrayList<E> o = new ArrayList<E>(e.length); for (int i = 0; i < e.length; i++) o.add(e[i]);// w w w .ja va 2 s . c om return o; } public static <E extends Object> List<E> toList(E e) { ArrayList<E> o = new ArrayList<E>(1); o.add(e); return o; } public static <E extends Object> List<E> toList(Collection<E> c) { if (c instanceof List) return (List<E>) c; ArrayList<E> o = new ArrayList<E>(c.size()); for (E e : c) o.add(e); return o; } }