difference between equals() and hashCode()

前端 未结 7 584
心在旅途
心在旅途 2021-02-05 13:29

I want a brief definition about the equals() , \"==\" and hashCode(). If i run following code means the output will be \"true false 2420395 2420395\". But i had understand that

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-05 14:27

    hashCode() does not return the object's reference, but a hash of the object, computed in some way. == does not compare objects using the value of hashCode() but, as you correctly say, by the value of the objects' references.

提交回复
热议问题