Java code to Prevent duplicate <Key,Value> pairs in HashMap/HashTable
<p>I have a HashMap as below (assuming it has 10,0000 elements)</p>

<p><code>HashMap&lt;String,String&gt; hm = new HashMap&lt;String,String&gt;();</code><br>
   <code>hm.put("John","1");</code><br>
   <code>hm.put("Alex","2");</code><br>
   <code>hm.put("Mike","3");</code><br>
   <code>hm.put("Justin","4");</code><br>
   <code>hm.put("Code","5");</code>     </p>

<pre><code>==========================
    Expected Output     
==========================  
</code></pre>

<p><code>Key = John",Value = "1"</code><br>
   <code>Key = Alex",Value = "2"</code><br>
   <code>Key = Mike",Value = "3"</code><br>
   <code>Key = Justin",Value = "4"</code><br>
   <code>Key = Code",Value = "5"</code><br>
   ===========================</p>

<p>I need Java code to prevent <code>Addition of Duplicate &lt;Key,Value&gt; Pairs</code> in HashMap such<br>
   that  below conditions are staisfied.<br>
  1> <code>hm.put("John","1"); is not accepted/added again in the Map</code><br>
  2> <code>hm.put("John","2"); is not accepted/added again in the Map</code>    </p>

<p>Hope its clear.
Java code provided will be appreciated.(generic solution needed since i can add any duplicate to the existing map)      </p>
