import java.util.ArrayList;标签:set,Java,ArrayList,new,重且,add,listWithDuplicateElements,LinkedHashSet From: https://blog.51cto.com/u_3871599/6138546
import java.util.LinkedHashSet;
public class MainClass
{
public static void main(String[] args)
{
//Constructing An ArrayList
ArrayList<String> listWithDuplicateElements = new ArrayList<String>();
listWithDuplicateElements.add("JAVA");
listWithDuplicateElements.add("J2EE");
listWithDuplicateElements.add("JSP");
listWithDuplicateElements.add("SERVLETS");
listWithDuplicateElements.add("JAVA");
listWithDuplicateElements.add("STRUTS");
listWithDuplicateElements.add("JSP");
LinkedHashSet<String> set = new LinkedHashSet<String>(listWithDuplicateElements);
ArrayList<String> listWithoutDuplicateElements = new ArrayList<String>(set);
System.out.print("ArrayList After Removing Duplicate Elements :");
System.out.println(listWithoutDuplicateElements);
}
}