public class DropRepetition { public static void main(String[] args) { Vector<String> v = new Vector<String>(); v.add("1"); v.add("1"); v.add("2"); v.add("2"); v.add("3"); v.add("3"); dropRepetition1(v); dropRepetition2(v); } private static Vector<String> dropRepetition1(Vector<String> v) { //创建新的Vector对象 Vector<String> newV = new Vector<String>(); for (String str : newV) { if(!newV.contains(str)) newV.add(str); } return newV; } private static HashSet<String> dropRepetition2(Vector<String> v) { //构造新的HashSet HashSet<String> set = new HashSet<String>(v); return set; } }