java的Vector用法示例

package com.huowolf;

import java.util.Enumeration;
import java.util.NoSuchElementException;
import java.util.Vector;

public class VectorTest {

	
	private static final String colors[] = {"red","white","blue"};
	public VectorTest()
	{
		Vector vector = new Vector();
	
		vector.add("black");
		for(int i=0;i vectorOutput) {
		if(vectorOutput.isEmpty())
			System.out.println("vector is empty!");
		else {
			System.out.println("vector contains:");
			Enumeration items = vectorOutput.elements();
			
			while(items.hasMoreElements())
				System.out.print(items.nextElement()+" ");
		}
		System.out.println();
	}

	public static void main(String[] args) {
		new VectorTest();
	}

}
java的Vector用法示例_第1张图片

你可能感兴趣的:(Java基础)