看到这个我就懵了:
public class Timestamp extends java.util.Date {
//...
public boolean equals(java.lang.Object ts) {
if (ts instanceof Timestamp) {
return this.equals((Timestamp)ts);
} else {
return false;
}
}
public int hashCode() {
return super.hashCode();
}
它确实以粗体记录Note
(参见https://docs.oracle.com/javase/7/docs/api/java/sql/Timestamp.html)
对我来说,做出这样一个非常糟糕的决定的原因是什么?当与 java.util.Date 对象进行比较时,为什么不调用 super.equals(this) 以使相等比较对称?