Vector集合特有功能:
添加
public void addElement(Object obj):在vector对象的末尾添加元素
删除
public boolean removeElement(Object obj):删除元素
获取功能
public Object elementAt(int index):获取指定位置的元素
类似于 public Object get(int index)
public Enumeration<E> elements() :Vector集合的专有遍历方式
类似于 Iterator literator()接口
boolean hasMoreElements():判断是否有更多的元素可以迭代
Object nextElement() 获取元素
public class VectorDemo {
public static void main(String[] args) {
//创建Vector集合对象
Vector<String> v = new Vector<>() ;
v.addElement("hello");
v.addElement("world");
v.addElement("SpringBoot");
v.addElement("SpringCloud") ;
//遍历:特有功能
Enumeration<String> en = v.elements(); //相当于Iterator
while(en.hasMoreElements()){
String s = en.nextElement();
System.out.println(s+"---"+s.length());
}
System.out.println("----------------------------------");
//增强for遍历数组
for(String s: v){
System.out.println(s+"----"+s.length());
}
}
}