Java tutorial
//package com.java2s; //License from project: Apache License import java.util.LinkedList; import java.util.List; public class Main { @SuppressWarnings("unchecked") public static <T> List<T> toGenericList(Iterable<?> it) { if (it instanceof List) { return (List<T>) it; } final List<T> result = new LinkedList<T>(); for (final Object t : it) { result.add((T) t); } return result; } }