私は次のようなクラスを持っています:
class BSTNode<K extends Comparable, V> {
K key;
BSTNode(K key, V value) { ... }
}
それから私は使用しています
node.key.compareTo(root.key) >= 0
node
とroot
はどこですかBSTNode
。その行で、チェックされていないエラーが発生しています。なんで?
warning: [unchecked] unchecked call to compareTo(T) as a member of the raw type Comparable
} else if (node.key.compareTo(root.key) >= 0) { // new node >= root
^
where T is a type-variable:
T extends Object declared in interface Comparable
1 warning
私の理解では、 で定義されているようにBSTNode
、K
を拡張/実装する必要がありますComparable
。それでnode.key.compareTo(root.key)
OKのはず?