/** Data Definition: IntList := new Empty() + new Cons(int, IntList) */ abstract class IntList { } class Empty extends IntList { int getFirst() { throw new IllegalArgumentException( "first requires a non Empty IntList"); } IntList getRest() { throw new IllegalArgumentException( "rest requires a non Empty IntList"); } } class Cons extends IntList { private int first; private IntList rest; /* constructor */ Cons(int f, IntList r) { first = f; rest = r; } /* accessors */ /** returns first element of non-empty list */ abstract int getFirst(); /** returns all but the first element of non-empty list */ IntList getRest() { return rest; } }