// file TestMyList.java // public class TestMyList { public static void main(String args[]) { MyList S = new MyList(); S.setValue("Fourscore"); MyList S2 = S.setNext(new MyList()); S2.setValue("and"); MyList S3 = S2.setNext(new MyList()); S3.setValue("seven"); System.out.println(S.toString()); // prints [Fourscore and seven ] MyList W = new MyList(); W.setValue(new Integer(6)); // What you mean, strictly speaking. W.setValue(6); // Also OK; Java figures out what you mean. MyList W2 = W.setNext(new MyList()); W2.setValue(28); MyList W3 = W2.setNext(new MyList()); W3.setValue(496); System.out.println(W.toString()); MyList X = new MyList(); X.setValue(6); MyList X2 = X.setNext(new MyList()); X2.setValue("Fourscore"); MyList X3 = X2.setNext(new MyList()); X3.setValue(6.4); System.out.println(X.toString()); // X = W; Does not work. A list of Integers is not a list of Objects! } // end main } // end TestMyList