I want to override the compareTo
method. I googled hard but couldn't find anything useful, because my K is not specifically defined (it is not like People(class example) with name, age).
I have file Node.java that I cannot edit.
public class Node<K extends Comparable<K>, V>
{
public K key;
public V value;
public Node<K, V> parent;
public Node<K, V> left;
public Node<K, V> right;
public Node(K key, V value, Node<K, V> parent, Node<K, V> left, Node<K, V> right)
{
this.key = key;
this.value = value;
this.parent = parent;
this.left = left;
this.right = right;
}
}
and I have the other file Heap.java
public class Heap<K extends Comparable<K>, V> {...}
I want to override compareTo method at Heap.java (inside {..}
here!) so I can compare Node's key and sort them.