Here you can find the source of convertCollectionToList(Collection
Parameter | Description |
---|---|
T | a parameter |
coll | An input Collection |
public static <T> List<T> convertCollectionToList(Collection<T> coll)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { /**//from w w w . ja v a 2 s .com * Converts an instance of List to an instance of Collection. * @param <T> * @param coll An input Collection * @return The input value coll if it is an instance of List. Else it will construct a list with the same values and return it. **/ public static <T> List<T> convertCollectionToList(Collection<T> coll) { if (coll instanceof List) { return (List<T>) coll; } else { List<T> theReturn = new ArrayList<T>(coll); return theReturn; } } }