Test of equality (equals and hash code method)

前端 未结 6 1508
挽巷
挽巷 2021-01-24 21:59

As per the below link

Hashcode and equals

So it is assumed that if 2 objects are equal (that is, equals() returns true), then their hashCodes() must retu

6条回答
  •  一向
    一向 (楼主)
    2021-01-24 22:26

    It is bad implementation of hashCode() , You should follow that contract.

    equals has nothing to do with hashcode independently.

    But when you use hashing data structure you should must follow this thing.

提交回复
热议问题