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

 

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

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

posted @ 2020-07-11 21:34  咔啡  阅读(174)  评论(0)    收藏  举报