import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
public class Hashset {
public static void main(String[] args){
ArrayList list = new ArrayList();
list.add("1"); list.add("2"); list.add("2");
@SuppressWarnings("unchecked")
HashSet hs = new HashSet(list);//以传参的形式new一个HashSet
list.clear();//去除所有元素
list.addAll(hs);
for(Iterator<String> it = list.iterator();it.hasNext();){
System.out.println(it.next()); }
}}