Java Iterable to List toList(Iterable iter)

Here you can find the source of toList(Iterable iter)

Description

Copies the elements of Iterable into a list and returns them.

License

Apache License

Parameter

Parameter Description
iter the iterable that contains the elements
E the type of the elements

Return

Returns the elements of the .

Declaration

public static <E> List<E> toList(Iterable<E> iter) 

Method Source Code


//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;
    }
}

Related

  1. iterableToList(Iterable input)
  2. iterableToList(Iterable iterable)
  3. iterableToSSV(Iterable list, String sep)
  4. toList(Iterable i)
  5. toList(Iterable items)
  6. toList(Iterable values)
  7. toList(Iterable protocols)
  8. toList(Iterable elements)
  9. ToList(Iterable inList)