Here you can find the source of toCollection(Iterable
public static <E> Collection<E> toCollection(Iterable<E> iterable)
//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> Collection<E> toCollection(Iterable<E> iterable) { List<E> collection = new ArrayList<E>(); iterable.forEach(e -> collection.add(e)); return collection; }/* w w w . j av a2s . c o m*/ }