Java examples for java.util:Collection to List
Convert Collection to Immutable List
//package com.java2s; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; public class Main { public static void main(String[] argv) { Collection c = java.util.Arrays.asList("asdf", "java2s.com"); System.out.println(toImmutableList(c)); }//ww w. j a v a 2 s. c o m public static <T> List<T> toImmutableList(final Collection<T> c) { if (c.isEmpty()) { return Collections.emptyList(); } else { return Collections.unmodifiableList(new ArrayList<T>(c)); } } }