/* This program compares insertions at the head of lists and vectors. More precisely, it creates a LinkedList and a Vector and inserts n elements at the head. It records the total time in each case. Usage: the user must enter on the command line the size to be tested. To run: java ListVect represents the size of the collection to be tested. Note: This shows an example of using the String[] parameter of main() Laura Toma */ import java.util.Vector; import java.util.LinkedList; public class ListVec { Vector vec; LinkedList list; public ListVec() { vec = new Vector(); list = new LinkedList(); } public static void main(String[] args) { ListVec x = new ListVec(); int n; if (args.length == 0) { System.out.println("usage: java ListVec "); } else { n = new Integer(args[0]); x.test(n); } } public void test(int n) { System.out.println("size n = " + n); long t1, t2; //start and end time System.out.print("inserting in vector: "); t1 = System.currentTimeMillis(); for (int i=0; i