As I understand it equal hash codes in general imply a high probability of equality between objects, but they aren't perfect. But I've been told that in Java the base hash code of an Object is simply the memory address of the object, so I've assumed that Object hash codes are effectively perfect(two objects can't occupy the same space in memory right?). But I've been relaying very heavily on this assumption for a program I'm writing and I've started to think I should really get a definitive answer on this instead of continuing with my assumption.
OffbeatPatriot 5 Junior Poster in Training
Recommended Answers
Jump to PostBut I've been told that in Java the base hash code of an Object is simply the memory address of the object
As has been implied already, someone told you wrong.
Jump to PostIt is extremely simple to determine that hashcodes are not unique.
A hashcode is a 32 bit integer, it is possible to create more object instances than fit inside a 32 bit integer. Ergo, a hashcode cannot possibly be unique, as there are more possible object instances than possible hashcodes …
All 6 Replies
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
BestJewSinceJC 700 Posting Maven
wildplace 0 Junior Poster in Training
masijade 1,351 Industrious Poster Team Colleague Featured Poster
OffbeatPatriot 5 Junior Poster in Training
jwenting 1,905 duckman Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.