Java Iterator to List toList(Iterator it)

Here you can find the source of toList(Iterator it)

Description

to List

License

Open Source License

Declaration

public static <T> List<T> toList(Iterator<T> it) 

Method Source Code

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

import java.util.ArrayList;

import java.util.Iterator;

import java.util.List;

public class Main {
    public static <T> List<T> toList(Iterator<T> it) {
        List<T> l = new ArrayList<T>();
        while (it.hasNext()) {
            l.add(it.next());// w  w w  .j  a va2 s . c  o m
        }
        return l;
    }
}

Related

  1. toList(Iterator iterator)
  2. toList(Iterator iterator)
  3. toList(Iterator src)
  4. toList(Iterator iterator)
  5. toList(Iterator iter)