1.

There Are Two Objects A And B With Same Hashcode. I Am Inserting These Two Objects Inside A Hashmap. Hmap.put(a,a); Hmap.put(b,b); Where A.hashcode()==b.hashcode() Now Tell Me How Many Objects Will Be There Inside The Hashmap?

Answer»

There can be two different elements with the same hashcode. When two elements have the same hashcode then JAVA USES the equals to further differentation. So there can be one or two OBJECTS DEPENDING on the content of the objects.

There can be two different elements with the same hashcode. When two elements have the same hashcode then Java uses the equals to further differentation. So there can be one or two objects depending on the content of the objects.



Discussion

No Comment Found