试试这个:- import java.util.Vector;
- public class Demo {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Vector<String> v = new Vector<String>();
- Vector<String> vs = new Vector<String>();
- v.add("abc");
- v.add("ab");
- v.add("abc");
- v.add("ac");
-
- for(String s : v){
- if(!vs.contains(s))
- vs.add(s);
- }
- System.out.println("v = "+v);
- System.out.println("vs = "+vs);
-
- }
- }
复制代码 输出结果:
v = [abc, ab, abc, ac]
vs = [abc, ab, ac]
|