Here you can find the source of asList(Iterator
public static <T> List<T> asList(Iterator<T> iterator)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; public class Main { public static <T> List<T> asList(Iterator<T> iterator) { List<T> list = new ArrayList<T>(); while (iterator.hasNext()) list.add(iterator.next());//from ww w . j a va 2s . c o m return list; } public static List<Long> asList(long... ls) { List<Long> list = new ArrayList<Long>(); for (long l : ls) list.add(l); return list; } public static List<String> asList(String... ss) { List<String> list = new ArrayList<String>(); Collections.addAll(list, ss); return list; } }