title: Compare hash map key with the string
body: <p>I want to compare the string with the key from the hashmap. I tried to use steps mentioned here <a href="https://stackoverflow.com/questions/16413143/compare-map-key-with-a-list-of-strings">Compare map key with a list of strings</a> but didn't work for me.</p>
  
  <p>The hashmap contains many entries and want to compare the string which I am passing. If the key matches the string it should stop there and print the value of matched string.
  Below is my code :</p>
  
  <pre><code>HashMap&lt;String, MyBO&gt; myObjs = MyData.getMyData();
  Set&lt;String&gt; keys = myObjs.keySet();
  String  id = "ABC";
  for(String code: keys) {
      MyBO bo  = myObjs.get(code);
      if(keys.contains(itemId)) {
          System.out.println("Matched key = " + id);
      } else {
          System.out.println("Key not matched with ID");
      }
  }
  </code></pre>