本帖最后由 Kevin.Kang 于 2015-7-17 14:42 编辑
- package com.kxg_Vector;
- import java.util.Enumeration;
- import java.util.Vector;
- /*
- * Vector类的特有功能:
- * 1:添加功能
- * public void addElement(Object obg):等同add()
- * 2:获取功能
- * public Object element(int index):等同get()
- * public Enumeration<E> elements()
- * 等同Iterator iterator()
- * hasMoreElements() 等同 hasNext()
- * nextElement() 等同 next()
- */
- public class VectorDemo {
- public static void main(String[] args) {
- // 定义集合
- Vector<String> vector = new Vector<>();
- // public void addElement(Object obg)
- vector.addElement("study");
- vector.addElement("java");
- vector.addElement("android");
- // public Object element(int index)
- System.out.println(vector.elementAt(1));
- // public Enumeration<E> elements()
- Enumeration<String> e = vector.elements();
- while (e.hasMoreElements()) {
- String s = e.nextElement();
- System.out.println(s);
- }
- }
- }
复制代码
|
|