/* Implements an integer list via inheritance See TIJ page 181 and JIAN page 64 NOTE: we are unable to redefine head() because we get a clash. IntList is a kind of List, therefore the head() method is inherited and must have same return type. We cannot redefine head() to deliver different return type, so we have a intHead() method. This seems to go against the polymorphic grain! */ public class IntList extends List { public IntList(){ super(); } public IntList(int e) { super(new Integer(e)); } public IntList(int e, IntList tail) { super(new Integer(e), tail); } public IntList add(int e) { return new IntList(e,this); } public int head() { return ((Integer)data).intValue(); // won't compile!! } }