Java examples for java.util:List Duplicate Element
collapse duplicate elements in a List
//package com.java2s; import java.util.HashSet; import java.util.List; import java.util.Set; public class Main { public static void main(String[] argv) { List list = java.util.Arrays.asList("asdf", "java2s.com"); System.out.println(asSet(list)); }//from w w w . ja v a2 s . co m /** * can be used to collapse duplicate elements * @param list any list of type T */ public static <T> Set<T> asSet(List<T> list) { return new HashSet<T>(list); } }