Here you can find the source of toList(Iterable
Parameter | Description |
---|---|
iter | the iterable that contains the elements |
E | the type of the elements |
public static <E> List<E> toList(Iterable<E> iter)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { /**/*www . j av a 2 s.c o m*/ * Copies the elements of {@link Iterable} into a list and returns them. * * @param iter the iterable that contains the elements * @param <E> the type of the elements * @return Returns the elements of the {@link Iterable}. */ public static <E> List<E> toList(Iterable<E> iter) { List<E> list = new ArrayList<E>(); for (E item : iter) { list.add(item); } return list; } }