H
HK
Does anyone have an idea why the interface
java.util.Comparator explicitly mentions the
equals() method which is anyway defined for
each Object?
The docs say:
Note that it is always safe not to override
Object.equals(Object). However, overriding
this method may, in some cases, improve
performance by allowing programs to determine
that two distinct Comparators impose the same order.
Well, but why would I generate a large number of
Comparators which do exactly the same? My typical
comparator looks rather like
public static final Comparator cmpBlaOnBlifield = new Comparator() {
// run comparison of Bla objects based on field bli
}
Harald.
java.util.Comparator explicitly mentions the
equals() method which is anyway defined for
each Object?
The docs say:
Note that it is always safe not to override
Object.equals(Object). However, overriding
this method may, in some cases, improve
performance by allowing programs to determine
that two distinct Comparators impose the same order.
Well, but why would I generate a large number of
Comparators which do exactly the same? My typical
comparator looks rather like
public static final Comparator cmpBlaOnBlifield = new Comparator() {
// run comparison of Bla objects based on field bli
}
Harald.