Java之Vector特有功能使用

package cn.spring04.Vector;

import java.util.Enumeration;
import java.util.Vector;
/**
 * public class Vector<E>  extends AbstractList<E>  implements List<E>, RandomAccess
 */
public class VectorDemo {

	public static void main(String[] args) {
		
		Vector<String> vector = new Vector<>();
		vector.addElement("hello");
		vector.addElement("world");
		vector.add("java");
		
		for (int i = 0; i < vector.size(); i++) {
			String  string = vector.get(i);
			System.out.println(string);
			
		}
		System.out.println("---------------------");
		Enumeration<String >enumeration = vector.elements();
		while (enumeration.hasMoreElements()) {
			String string = enumeration.nextElement();
			
			System.out.println(string);
			
		}
	}
}


你可能感兴趣的:(Java之Vector特有功能使用)