/** Class MyBetterIntList */ import java.util.ArrayList; public class MyBetterIntList { // field to hold the data array private int[] data; private int num_elems; /** constructor for MyBetterIntList * make an empty list */ public MyBetterIntList() { this.data = new int[10]; this.num_elems = 0; } /** Return the String rep of the array * @return the string rep of the array */ public String toString() { String ret = ""; int len = this.num_elems; for (int i = 0; i aList = new ArrayList(); for (int i =0; i<1000000; i++) { //if (i % 10000 == 0) System.out.println(i); aList.add(i); } long endTime = System.currentTimeMillis(); System.out.println( "Time for ArrayLists: " + (endTime-startTime) ); // add 1 million integers to an ArrayList startTime = System.currentTimeMillis(); MyBetterIntList list = new MyBetterIntList(); for (int i =0; i<1000000; i++) { //if (i % 10000 == 0) System.out.println(i); list.add(i); } endTime = System.currentTimeMillis(); System.out.println( "Time for MyBetterIntList: " + (endTime-startTime) ); } // end main } // end class