17
What's the reasoning behind decision to include these methods in the java.lang.Object? Equality and hashing doesn't make sense for many classes.
It would be more logical to make two interfaces:
interface Equalable {
boolean equals(Equalable other);
}
interface Hashable extends Equalable {
int hashCode();
}
For example HashSet definition might look like
class HashSet<T extends Hashable> ...
It would prevent one of the common beginner mistakes - using set of items without implementing equals/hashCode.