Here you can find the source of iterableToCollection(Iterable extends T> c, Collection
private static <T> void iterableToCollection(Iterable<? extends T> c, Collection<T> list)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.List; public class Main { private static <T> void iterableToCollection(Iterable<? extends T> c, Collection<T> list) { for (T element : c) { list.add(element);/*from ww w. j a va2 s . c om*/ } } /** * Adds the given item to the list at specified <code>index</code>. * <p/> * if <code>index</code> is greater than list size, it simply appends to the * list. * * @param list * collection of elements * @param index * specific index * @param item * object to add. */ public static <E, T extends E> void add(List<E> list, int index, T item) { if (index < list.size()) { list.add(index, item); } else { list.add(item); } } }