abstract class List { // Any List, of any subclass, can tell us its length. // However, the code must wait, since Lists can be either // an instance of Cons or Null. // abstract public int length(); /* List.main * A test suite. * This method should be inside the class List. */ public static void main( String[] args ) { List l1, l2; l1 = new Null(); l2 = new Cons( 3, new Cons( 5, new Cons( 4, new Null() ))); System.out.println( "l1 is " + l1 + ", with length " + l1.length() + "." ); System.out.println( "l2 is " + l2 + ", with length " + l2.length() + "." ); } } class Null extends List { public int length() { // --- you'll complete this function momentarily! --- return -99; } } class Cons extends List { public int car; public List cdr; public Cons( int datum, List rest ) { // The constructor for a Cons object car = datum; // (this is what "new" calls). cdr = rest; } public int length() { // --- you'll complete this function momentarily! --- return -99; } }