I am designing an implementation of a BinarySearchTree, although I am stuck with an issue that I have not encountered before. I also have little understanding of how to fix this:
The type K is not a valid substitute for the bounded parameter <K extends Comparable<? super K>> of the type BST<K,V>
This is the error I get after creating an abstract class named BST<K extends Comparable<? super K>, V>
and then having another class that extends this named RectangleBST<K,V>
. So RectangleBST<K,V> extends BST<K,V>
but I get the error when I use BST<K, V>
.
One solution was to use extends BST<Integer, Rectangle>
, although would that mean that I have now inherited the methods specifically for a Key of Integer type and a Value of Rectangle type?
Another may be to have the comparable in the RectangleBST instead, although I believe that my plan is to compare keys in BST rather than RectangleBST?