主要是说一下 equals 和 hashcode
1.hashCode
2.equals 5.对于 non-null reference x ,满足 x.equals(x) return true。 5. 对于 non-null reference x,y 满足 对称性 即:如果 x.equals(y) return true ,则 y.equals(x) 也会 return true 。 6. 对于 non-null reference x,y,x 满足 传递性。即:如果 x.equals(y) return true 和 y.equals(z) return true,那么 x.equals(z) 也应该 return true 。 7. 对于任何 non-null reference x,y,满足一致性,x.equals(y) 要是 true永远是true 8. 对于任何 non-null reference x, x.equals(null) return false. 9. 当重写 equals 方法是必须需要重写 hashCode,这样才能保证 equals 为true的两个对象的 hashCode也一样。(jre 中就有违背这条的类存在)