Q:

insert duplicate keys to hash map

I have created hash map and when I debug it I saw that I have duplicte keys.
I didnt override the hashCode() & equals(Object obj) in the key - Object1
and i wonder how will it affect the performance of the map search?
private HashMap<Object1,Object2> map = new HashMap<Object1,Object2>();

A:

It is not possible to have duplicate keys in a Map, you have different keys that "appear" the same (Maybe based on their toString()? )because you have not overridden equals() and hashCode(), but in reality the keys are different.
This means that in order to get all values from your Map you need to keep every key you created and store it somewhere, which to me defeats the purpose of the Map.
Summary: 
Override equals() and hashCode(), then put your key/value pairs into the Map.

