title: Reverse HashMap keys and values in Java
body: <p>It's a simple question,
  I have a simple HashMap of which i want to reverse the keys and values.</p>
  
  <pre><code>HashMap&lt;Character, String&gt; myHashMap = new HashMap&lt;Character, String&gt;();
  myHashMap.put('a', "test one");
  myHashMap.put('b', "test two");
  </code></pre>
  
  <p>and I want to create a new HashMap in which i put the opposites.</p>
  
  <pre><code>HashMap&lt;String, Character&gt; reversedHashMap = new HashMap&lt;String, Character&gt;();
  e.g. Keys "test one" &amp; "test two" and values 'a' &amp; 'b'.
  </code></pre>