Java tutorial
//package com.java2s; import java.util.*; public class Main { /** * Converts the elements passed into a list. * Almost the same as Java's Collections.asList, but returns an ArrayList. */ // @SafeVarargs public static <T> ArrayList<T> asList(T... strings) { ArrayList<T> list = new ArrayList<T>(strings.length + 1); for (T s : strings) { list.add(s); } return list; } /** * Converts the elements found in the given Enumeration into a list. */ public static <T> List<T> asList(Enumeration<T> enu) { List<T> list = new ArrayList<T>(); while (enu != null && enu.hasMoreElements()) { list.add(enu.nextElement()); } return list; } /** * Converts the elements found in the given Iterator into a list. */ public static <T> List<T> asList(Iterator<T> itr) { List<T> list = new ArrayList<T>(); while (itr != null && itr.hasNext()) { list.add(itr.next()); } return list; } }