Java Iterator to ArrayList toArrayListFromIterator(Iterator iterator)

Here you can find the source of toArrayListFromIterator(Iterator iterator)

Description

to Array List From Iterator

License

Open Source License

Declaration

public static <T> ArrayList<T> toArrayListFromIterator(Iterator<T> iterator) 

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 <T> ArrayList<T> toArrayListFromIterator(Iterator<T> iterator) {
        ArrayList<T> r = new ArrayList<T>();
        while (iterator.hasNext())
            r.add(iterator.next());//from   www .jav a  2  s .co  m
        return r;
    }
}