Reputation: 4771
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.
Upvotes: 0
Views: 364
Reputation: 234795
That's the wrong syntax. Try this:
public class BinaryTree<K extends Number & Comparable<? super K>, E>
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.
Upvotes: 5