title: How to print keys with duplicate values in a hashmap?
body: <p>I have a hashmap with some keys pointing to same values. I want to find all the values that are equal and print the corresponding keys. </p>
  
  <p>This is the current code that I have: </p>
  
  <pre><code>    Map&lt;String, String&gt; map = new HashMap&lt;&gt;();
  
      map.put("hello", "0123");
      map.put("hola", "0123");
      map.put("kosta", "0123");
      map.put("da", "03");
      map.put("notda", "013");
  
      map.put("twins2", "01");
      map.put("twins22", "01");
  
  
      List&lt;String&gt; myList = new ArrayList&lt;&gt;();
  
      for (Map.Entry&lt;String, String&gt; entry : map.entrySet()) {
         for (Map.Entry&lt;String, String&gt; entry2 : map.entrySet()){
             if (entry.getValue().equals(entry2.getValue()))
             {
                 myList.add(entry.getKey());
             }
         }
  
      }
  </code></pre>
  
  <p>The current code adds the duplicates two times into the list, however it also adds every key one time. </p>
  
  <p>Thanks.</p>