// implementer public class ArrayIntList { // fields - data // encapsulation private int[] elementData; private int size; // constructor public ArrayIntList() { elementData = new int[100]; size = 0; } public void add(int value) { elementData[size] = value; size++; } public String toString() { if (size == 0) { return "[]"; } else { String result = "[" + elementData[0]; // important: this loop is up until size, not elementData.length // because we need to maintain the illusion to the client that the // list grows and shrinks for (int i = 1; i < size; i++) { result += ", " + elementData[i]; } result += "]"; return result; } } }