I want to understand what is the difference between these two methods? Can they both be used for the same problem? Or are they designed for different cases?
public int compareTo(Coordinates o) {
if (row < o.row) return -1;
if (row > o.row) return +1;
if (column < o.column) return -1;
if (column > o.column) return +1;
return 0;
}
@Override
public int compareTo(Coordinates o) {
int cmp = row - o.row;
if (cmp == 0)
cmp = column - o.column;
return cmp;
}