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