I have a Generic Class with two type variables, which implements java.lang.Comparable.
public class DoubleKeyimplements Comparable
First way: use hashCodes, like
public int compareTo(DoubleKey aThat){
getFirstKey().hashCode() + getSecondKey().hashCode() - aThat.getFirstKey().hashCode() + aThat.getSecondKey().hashCode();
}
(you should think more about formula)
Second way: add comparator to constructor
public DoubleKey(K key1, J key2, Comparator cmp){