Java examples for java.util:Collection to List
Convert Collection to List
//package com.java2s; import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { public static <T> List<T> toList(T[] array) { if (array == null) { return new ArrayList<T>(); }//from w ww . j a v a 2 s .c o m ArrayList<T> result = new ArrayList<T>(); for (T item : array) { result.add(item); } return result; } public static <T> List<T> toList(Collection<T> collection) { if (collection == null) { return new ArrayList<T>(); } ArrayList<T> result = new ArrayList<T>(); for (T item : collection) { result.add(item); } return result; } }