Why was hashcode designed to return int [duplicate]

為{幸葍}努か 提交于 2019-12-13 05:17:52

问题


It seems like a hashcode always returns an int. Now this appears to be a limiting factor due to IntMax. Now one can argue that such we would never have so many objects, as it would cause heap overflow etc. But if we chose double instead of int then we could guarantee with a much larger extent that hashcode wont be unique for distinct objects ?


回答1:


Hashcodes don't need to be unique. That's why they are hashcodes. For use in hashing algorithms. Which don't need unique keys.



来源:https://stackoverflow.com/questions/19214537/why-was-hashcode-designed-to-return-int

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!