Source Code : Remove duplicate items from an ArrayList
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Remove duplicate items from an ArrayList
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
public class Main {
public static void main(String[] argv) {
List<String> arrayList1 = new ArrayList<String>();
arrayList1.add("A");
arrayList1.add("A");
arrayList1.add("B");
arrayList1.add("B");
arrayList1.add("B");
arrayList1.add("C");
HashSet<String> hashSet = new HashSet<String>(arrayList1);
List<String> arrayList2 = new ArrayList<String>(hashSet);
for (Object item : arrayList2)
System.out.println(item);
}
}
/*
A
B
C
*/
Thank with us