Here you can find the source of toCollection(Iterable
Parameter | Description |
---|---|
i | a parameter |
public static <T> Collection<T> toCollection(Iterable<T> i)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.Collection; public class Main { /**/*from w w w .ja va 2 s . c om*/ * Convert an Iterable to a Collection (ArrayList under the hood). All items in the * Iterable will be retained. * @param i * @return */ public static <T> Collection<T> toCollection(Iterable<T> i) { if (i == null) { throw new IllegalArgumentException("Iterable 'i' cannot be null"); } Collection<T> c = new ArrayList<T>(); for (T t : i) { c.add(t); } return c; } }