// This program demonstrates a client program // that utilizes the ArrayIntList class to // create two lists and adds numbers to the // lists. // Today we modified the program to call our remove method and constructors. import java.util.*; public class ArrayIntListClient { public static void main(String[] args) { ArrayIntList list1 = new ArrayIntList(100); ArrayIntList list2 = new ArrayIntList(); list1.add(6); list1.add(43); list1.add(12); list1.add(3275); list1.add(999); // 0 1 2 3 4 5 list1.add(97); // [6, 43, 12, 3275, 0, 97] list2.add(72); list2.add(-8); // [72, -8] System.out.println(list1); // client cannot modify the object now, because it is encapsulated // list1.size = 99999999; // list1.elementData = new int[2]; // testing the size and get "accessor" methods System.out.println("The list has " + list1.size() + " elements!"); for (int i = 0; i < list1.size(); i++) { System.out.println("element " + i + " is " + list1.get(i)); } // testing the remove method list1.remove(3); System.out.println(list1); list1.remove(0); System.out.println(list1); list1.remove(3); System.out.println(list1); list1.remove(1); System.out.println(list1); list1.remove(0); System.out.println(list1); list1.remove(0); System.out.println(list1); } }