Here you can find the source of castList(Class extends T> clazz, Collection> c)
private static <T> List<T> castList(Class<? extends T> clazz, Collection<?> c)
//package com.java2s; //License from project: LGPL import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { private static <T> List<T> castList(Class<? extends T> clazz, Collection<?> c) { List<T> r = new ArrayList<T>(c.size()); for (Object o : c) r.add(clazz.cast(o));/*from ww w . java 2s . c om*/ return r; } }