为什么在重写 equals 方法的时候需要重写 hashCode 方法?

 

因为有强制的规范指定需要同时重写 hashcode  equal 是方法许多容器类

 HashMap、HashSet 都依赖于 hashcode  equals 的规定

原文地址:https://www.cnblogs.com/programb/p/13018934.html