为什么在重写 equals 方法的时候需要重写 hashCode 方法? 因为有强制的规范指定需要同时重写 hashcode 与 equal 是方法,许多容器类, 如 HashMap、HashSet 都依赖于 hashcode 与 equals 的规定。