// This is the playground and driver
import java.util.Vector;
import javax.swing.JButton;
public class Lab1_8 {
private static int i = 4;
private int total = 0;
//private Lab1_8 bill = new Lab1_8();
public static void main(String[] args) {
Vector v = new Vector(15, 10);
IntVector v2 = new IntVector();
for (int i = 20; i > 0; i--) {
v2.add( i );
}
System.out.println( v2.get(3) );
v.add("Peter");
v.add("Eric");
//String s = (String)v.get(20);
Object [] x = v.toArray();
for (int i = 0; i < x.length; i++) {
//System.out.print( x[i].toString() );
}
System.out.println( v.indexOf(new Integer(2) ));
System.out.println( v2 );
System.out.println( v.capacity() );
}
public void foo() {
System.out.println("hello from foo");
}
}
// This is the IntVector
import java.util.Vector;
public class IntVector {
private Vector numbers = new Vector();
public String toString() {
return numbers.toString();
}
public boolean add(int number) {
numbers.add( new Integer(number) );
return true;
}
public int size() {
return numbers.size();
}
public int get(int index) {
// add error checking
return ((Integer)numbers.get(index)).intValue();
}
}