Java ArrayList Create newArrayList(Iterable iterable)

Here you can find the source of newArrayList(Iterable iterable)

Description

new Array List

License

Open Source License

Declaration

public static <E> ArrayList<E> newArrayList(Iterable<E> iterable) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.Iterator;

public class Main {
    public static <E> ArrayList<E> newArrayList(Iterable<E> iterable) {
        if (iterable == null) {
            throw new NullPointerException();
        }/* w  w w .jav a 2 s .  c  o m*/
        ArrayList<E> list = new ArrayList<E>();
        for (Iterator<E> i = iterable.iterator(); i.hasNext();) {
            list.add(i.next());
        }
        return list;
    }
}

Related

  1. newArrayList(int initialCapacity)
  2. newArrayList(int initialCapacity)
  3. newArrayList(int initialCapacity)
  4. newArrayList(int size)
  5. newArrayList(Iterable elements)
  6. newArrayList(T anObj)
  7. newArrayList(T... elements)
  8. newArrayList(T... items)
  9. newArrayList(T... objectList)