difference between equals() and hashCode()

前端 未结 7 602
心在旅途
心在旅途 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条回答
  • 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.

    0 讨论(0)
提交回复
热议问题