I'd compare more than one only field of a object using the compareTo
method. Is it possible?
for istance:
public int compareTo(Object o) {
return field.compareTo(o.field);
}
I create this method to sort a collection. Obviously my object has to implement Comparable
interface.
I'm guessing if is possible to compare not only one field in the same method compareTo
.