public class VectorDemo
1: //VectorDemo.java
2:
3: import java.util.*;
4:
5: public class VectorDemo
6: {
7: public static void main(String[] args)
8: {
9: Vector<String> toDoList = new Vector<String>(10);
10: System.out.println( "Enter items for the list, when prompted.");
11: boolean done = false;
12: String next = null;
13: String ans;
14: Scanner keyboard = new Scanner(System.in);
15:
16: while (! done)
17: {
18: System.out.println("Input an entry:");
19: next = keyboard.nextLine( );
20: toDoList.addElement(next);
21: System.out.print("More items for the list? ");
22:
23: ans = keyboard.next( );
24: keyboard.nextLine( );
25: if (!(ans.equalsIgnoreCase("yes")))
26: done = true;
27: }
28:
29: System.out.println("The list contains:");
30: int position;
31: int vectorSize = toDoList.size( );
32: for (position = 0; position < vectorSize; position++)
33: System.out.println(toDoList.elementAt(position));
34: }
35: }
36: