Java examples for Collection Framework:Array Convert
Convert array and Iterator as List
//package com.book2s; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class Main { public static <E> List<E> asList( @SuppressWarnings("unchecked") final E... array) { List<E> list = new ArrayList<>(array.length); for (E element : array) { list.add(element);/*from www . j a v a 2 s . co m*/ } return list; } public static <E> List<E> asList(final Iterator<? extends E> iterator) { List<E> list = new ArrayList<>(); while (iterator.hasNext()) { list.add(iterator.next()); } return list; } }