package com.yjf.esupplier.common.test; import java.util.Enumeration; import java.util.Vector; /** * @author shusheng * @description * @Email shusheng@yiji.com * @date 2018/12/12 15:48 */ public class VectorDemo { /** * Vector 类概述 * 底层数据结构是数组,查询快,增删慢线程安全,效率低 * Vector 类特有功能 * 添加功能: * public void addElement(E obj) * 获取功能: * public Object elementAt(int index) public Enumeration elements() */ public static void main(String[] args) { Vector v = new Vector(); v.add("hello"); v.add("world"); v.add("java"); //遍历元素 for (int i = 0; i < v.size(); i++) { String s = (String) v.get(i); System.out.println(s); } System.out.println("----------------------------"); Enumeration en = v.elements(); while (en.hasMoreElements()) { System.out.println(en.nextElement()); } } }