2-7-00 Reuse of classes Ex. class LinkedList { Object value; LinkedList Next; Object Head() {Return value;} LinkedList Tail() {Return Next;} LinkedList(Object O) {value = 0; next = null;} } Object is the ultimate parent to all classes to allow general modularity This class is heterogeneous because it allows each node to have a different type. A int followed by a string etc. if you wanted a LinkedList of ints - you can't because int is a primitive class to solve this you use a wrapper class Integer Ex. LinkdList L = new LinkedList(new Integer(123)); When you want to extract from the list you need to use a cast. Integer I = (Integer)L.Head(); An alternative solution is parametric polymorphism as in PIZZA which allows explicit type parameters Ex. class LinketList { T value; LinkedList next; T Head() {return value;} LinkedList Tail() {return next;} LinkedList(T O) {value = 0; next = null;} } This is a homogeneous linkedlist because it will take one type at initialization. LinkedList L = new LinkedList(123); int I = L.Head(); This is a much simpler solution. Ad Hoc Polymorphism is allowed in C++ and Java 1) reuse of names in same class- ie. Every class should have a ToString method 2) A) overloading - reuse of names in same scope class C { insert(int I) {...} insert(char c) {...} } C cval = new c(); cval.insert? The compiler looks at the number and/or type and/or order in the parameters to determine the method called. You can't use the result type to determine the method. Because casting and you must use the context to decide. It is possible to determine in some cases. B) C++ allows overloading of operations -Java does not allow this yet class C { int I; public ... int operator+(int j) {return I+j} }