/** Class MyIntList */ import java.util.ArrayList; public class MyIntList { // field to hold the data array private int[] data; /** constructor for MyIntList * make an empty list */ public MyIntList() { this.data = new int[0]; } /** Return the String rep of the array * @return the string rep of the array */ public String toString() { String ret = ""; int len = this.data.length; 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(); MyIntList list = new MyIntList(); 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 MyIntList: " + (endTime-startTime) ); } // end main } // end class