问题
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