Java Vector遍历方法

import java.util.*;
public class TestVector {
public static void main(String[] args) {
    Vector S_vec=
        new Vector();
    S_vec.add("one");
    S_vec.add("two");
    S_vec.add("three");
    S_vec.add("four");
    S_vec.add("five");
    for(Iterator ite=S_vec.iterator(); ite.hasNext();) {
        System.out.println(ite.next());
    }

    Iterator ite=S_vec.iterator();
    while(ite.hasNext()) {
        System.out.println(ite.next());
    }

    Enumeration e=S_vec.elements();
    while(e.hasMoreElements()) {
        System.out.println(e.nextElement());
    }

}
}

你可能感兴趣的:(Java)