// CSE 143, Summer 2012 // This class captures common code shared by both the ArrayList and LinkedList. // An abstract class is a good way to provide a partially implemented class, or // a partial implementation of an interface. Notice that the header of this // class claims to implement the List interface, but the file doesn't write // all of the methods. // // Java allows this file to compile because it knows that the abstract class // must be extended to complete it. If a subclass of AbstractList doesn't // implement all the rest of the List interface's methods, that subclass will // not compile. public abstract class AbstractList implements List { // adds the given value to the end of the list. // resize if necessary public void add(E value) { add(size(), value); } // returns true if the list does not contain any elements. public boolean isEmpty() { return size() == 0; } // returns true if the list contains the given int value public boolean contains(E value) { return (indexOf(value) != -1); } }