Stephan van Hulst wrote:Campbell's form is more flexible. It won't change the way your method works, but it will allow the client to use more argument types.
For instance, if you have a class Fruit extends Comparable<Fruit>, and you have a class Pear extends Fruit, then your current method will only be able to accept Fruits, and not Pears. Using the wildcard, your method can take Pears as well, without any extra effort on your part.
Campbell Ritchie wrote:By the way, your hasLeft() method is poor style. It would be far better to writeThe generic form is <T extends Comparable<? super T>>
Stephan van Hulst wrote:Hi, Lido. You should probably make your printTree method recursive, so it will print all the nodes in the tree, and it will prevent your code from throwing NullPointerExceptions.
As for your other problem, your addRight method doesn't seem to be working. Take a good look