I am creating a Map with stores some data and i want the map to throw an exception if a duplicate value is tried to insert.
Map <Integer, String> temp;
temp.put(1, "hi");
temp.put(1, "hello");
Here this map should throw an error since a key '1' is already present. It can throw an error or does not compile. Is there any map which has said functionality?