Java examples for java.util:List Creation
Make a list without duplicates.
//package com.java2s; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; public class Main { public static void main(String[] argv) { List list = java.util.Arrays.asList("asdf", "java2s.com"); System.out.println(withoutDuplicates(list)); }/* w w w.j av a 2s . c o m*/ /** * Make a list without duplicates. * @param list list to process * @return a list without duplicates */ public static <E> List<E> withoutDuplicates(List<E> list) { return new ArrayList<>(new LinkedHashSet<>(list)); } }