// // Puts some values into a Vector and selectively print them out. // Notice that we do not know in advance how many elements will be stored. // // // Created by Charlie McDowell on Thu Jan 08 2004. // import java.util.Vector; import tio.*; public class VectorExample { public static void main(String[] args) { Vector list = new Vector(); String value; int index; System.out.println("Enter a string." + " Enter 'exit' as the string when done."); value = Console.in.readLine(); while (!value.equals("exit")) { list.add(value); System.out.println("Enter a string." + " Enter 'exit' as the string when done."); value = Console.in.readLine(); } System.out.println("Enter an integer between 0 and " + (list.size()-1) + ". Type '-1' when done."); index = Console.in.readInt(); while (index != -1) { System.out.println("The value associated at " + index + " is \"" + list.elementAt(index) + "\""); System.out.println("Enter an integer between 0 and " + (list.size()-1) + ". Type '-1' when done."); index = Console.in.readInt(); } } }