I am trying to create a BinarySearchTree using generics, but I am bumping into an error. I want my class to extend Number and Implement Comparable. So I declare it this way:
public class BinaryTree<K extends Number implements Comparable<? super K>, E>
But I am getting an error.
File: F:\Java\intro-prog-java\bookClasses\Lab_5\BinaryTree.java [line: 1]
Error: > expected
I cannot get whats wrong with it.
That’s the wrong syntax. Try this:
This syntax is described in the Bounded Type Parameters topic of the Java tutorials on generics as well as §4.4 of the Java Language Specification.