Java List remove duplicate elements
import java.util.ArrayList; import java.util.HashSet; import java.util.Set; import java.util.List; public class Main { public static void main(String[] argv) { List<String> arrayList1 = new ArrayList<String>(); arrayList1.add("CSS"); arrayList1.add("CSS"); arrayList1.add("HTML"); arrayList1.add("HTML"); arrayList1.add("HTML"); arrayList1.add("Java"); System.out.println(arrayList1); //from w w w .j a va2 s . c o m Set<String> hashSet = new HashSet<String>(arrayList1); List<String> arrayList2 = new ArrayList<String>(hashSet); System.out.println(arrayList2); } }