Computer Science, asked by hjjjd5307, 1 year ago

What happens if two keys produce same hashcode in hash table?

Answers

Answered by raaj25
0
They will just be added to the same bucket and equals() will be used to distinguish them. Each bucket can contain a list of objects with the same hash code.

In theory you can return the same integer as a hash code for any object of given class, but that would mean that you loose all performance benefits of the hash map and, in effect, will store objects in a list.

I hope it help you..
Please mark me brainlist
Answered by Sadhiti
15

Answer:

Answer

  • They will just be added to the same bucket and equals() will be used to distinguísh them. Each bucket can contain a list of objects with the same hash côde.

  • In theory you can return the same integer as a hash côde for any object of given class, but that would mean that you loose all performance benefits of the hash map and, in effect, will store objects in a list.
Similar questions