Java ArrayList Create newArrayList(final Iterator iter)

Here you can find the source of newArrayList(final Iterator iter)

Description

new Array List

License

Open Source License

Declaration

private static <T> List<T> newArrayList(final Iterator<T> iter) 

Method Source Code

//package com.java2s;

import java.util.ArrayList;
import java.util.Collections;

import java.util.Iterator;
import java.util.List;

public class Main {
    private static <T> List<T> newArrayList(final Iterator<T> iter) {
        if (!iter.hasNext()) {
            return Collections.emptyList();
        }/*ww w .j av  a  2 s  . c  o  m*/
        final List<T> result = new ArrayList<T>();
        while (iter.hasNext()) {
            result.add(iter.next());
        }
        return result;
    }
}

Related

  1. newArrayList(Collection c)
  2. newArrayList(Collection collection)
  3. newArrayList(E... elements)
  4. newArrayList(E... elements)
  5. newArrayList(final Collection elements)
  6. newArrayList(int initialCapacity)
  7. newArrayList(int initialCapacity)
  8. newArrayList(int initialCapacity)
  9. newArrayList(int initialCapacity)