[:IntList] UML (Unified Modeling Language) class diagram for IntList.   /** * Data Definition: IntList := new Empty() + new Cons(int, IntList) */abstract class IntList { /** * throws an IllegalArgumentException on Empty * returns first element of non-empty list */ abstract int getFirst(); /** * given the elements of this appear in non-descendin order * returns this with e inserted in nonde */ abstract IntList getRest(); abstract String toStringHelp(); } /** * Represents the unique empty list using the singleton pattern. * This is also an example of the Null Object pattern. * Note the use of exceptions to express programming errors in getFirst() and * getRest(). */class Empty extends IntList { /** * Singleton pattern. */ static Empty only = new Empty(); private Empty() {} int getFirst() { throw new IllegalArgumentException("An Empty IntList has no first."); } IntList getRest() { throw new IllegalArgumentException("An Empty IntList has no rest."); } public String toString() { return "()"; } String toStringHelp() { return ""; } } /** * Represents a non-empty list. * Note the use of the toStringHelp() "helper" method to "help" compute the * String representation of the rest. */class Cons extends IntList { int first; IntList rest; Cons(int f, IntList r) { first = f; rest = r; } int getFirst() { return first; } IntList getRest() { return rest; } /** * no leading space before first */ public String toString() { return "(" + first + rest.toStringHelp() + ")"; } /** * leading space before each elt */ String toStringHelp() { return " " + first + rest.toStringHelp(); } }