ArrayList.java - package jsjf import jsjf.exceptions import...

This preview shows page 1 - 3 out of 5 pages.

package jsjf; import jsjf.exceptions.*; import java.util.*; /** * ArrayList represents an array implementation of a list. The front of * the list is kept at array index 0. This class will be extended * to create a specific kind of list. * * @author Java Foundations * @version 4.0 */ public abstract class ArrayList<T> implements ListADT<T>, Iterable<T> { private final static int DEFAULT_CAPACITY = 100; private final static int NOT_FOUND = -1; protected int rear; protected T[] list; protected int modCount; /** * Creates an empty list using the default capacity. */ public ArrayList() { this(DEFAULT_CAPACITY); } /** * Creates an empty list using the specified capacity. * * @param initialCapacity the integer value of the size of the array list */ public ArrayList(int initialCapacity) { rear = 0; list = (T[])(new Object[initialCapacity]); modCount = 0; } /** * Creates a new array to store the contents of this list with * twice the capacity of the old one. Called by descendant classes * that add elements to the list. */ protected void expandCapacity() { // To be completed as a Programming Project } /** * Removes and returns the last element in this list. * * @return the last element in the list * @throws EmptyCollectionException if the element is not in the list */ public T removeLast() throws EmptyCollectionException { // To be completed as a Programming Project return null; // temp }
/** * Removes and returns the first element in this list.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture