使用枚举,遍历ArrayList类
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Vector;
public class Demo {
public static void main(String[] args) {
ArrayList list = new ArrayList();
list.add("王昭君");
list.add("杨玉环");
list.add("西施");
list.add("貂蝉");
//方式一:
Vector v= new Vector(list);
Enumeration elements = v.elements();
while(elements.hasMoreElements()){
Object nextElement = elements.nextElement();
System.out.println(nextElement);
}
//方式二:
Vector v1 = new Vector();
v1.addAll(list);
}
}