Rd Dari wrote:I have a question that if there are two objects of HashMap and their hashcode is same what will happen?
Simple answer: They will be be put in the same "bucket", providing that the two objects you talk about are KEYS, not VALUES.
What is a bucket? Like Jelle said: you need to do some more reading.
Specifically, one of the things you need to understand is
what a Map is: it's a relation between a KEY and it's VALUE.
And in
Java, it is a
1:1 relationship (ie, a key can have only ONE value) - and in a HashMap, it's the KEY that is hashed, NOT the value.
Sorry for all the caps, but it's important stuff; if you don't understand
that, then the business of understanding HashMaps is going to be difficult.
Winston