import java.util.ArrayList;import java.util.HashSet;import java.util.Iterator;import java.util.List;import java.util.Set;public class TestSet { public static void main(String[] args) { List list = new ArrayList(); list.add("zhaopeng"); list.add("zhaopeng"); list.add("zhaopeng"); list.add("momo"); list.add("momo"); list.add("momo"); for (Iterator iterator = list.iterator(); iterator.hasNext();) { String object = (String) iterator.next(); System.err.println(object); } System.err.println("----------------------"); List newList = TestSet.removeList(list); for (Iterator iterator = newList.iterator(); iterator.hasNext();) { String object = (String) iterator.next(); System.err.println(object); } } public static List removeList(List list) { Set someList = new HashSet(list); List newList = new ArrayList(); for (Iterator iterator = someList.iterator(); iterator.hasNext();) { Object object = (Object) iterator.next(); newList.add(object); } return newList; }}