Source code for WhileVectorExample.java:

import java.util.*;

public class WhileVectorExample
{
	public static void main(String args[])
	{
		// WhileVectorExample
		// Assume this exists somewhere:
		Vector v = new Vector();
		// Add elements to v;
		v.add(new String("Four"));
		v.add(new String("score"));
		v.add(new String("and"));
		v.add(new String("seven"));
		v.add(new String("years"));
		v.add(new String("ago"));
		// Later . . .
		Enumeration e = v.elements();
		while (e.hasMoreElements())
		{
			Object o = e.nextElement();
			System.out.println(o);
		}
	}
}

Output from WhileVectorExample.java:

Four score and seven years ago

--- Output Ends ---

NOTE:

You are reading previously generated output. You are not currently running the WhileVectorExample application at the momement. You need to compile and run the source code first.

To run this program:


Authors: Kevin Chu and Eric Brower
Copyright 2000 Prentice Hall PTR