title: Changing an object which is used as a Map key
body: <p>Let V be a class with a single attribute named K and its getter and setters.</p>
  
  <p>What's supposed to happen if I do:</p>
  
  <pre><code>V v = new V();
  v.setK("a");
  HashMap&lt;K,V&gt; map = new HashMap&lt;K,V&gt;();
  map.put(v.getk(),v);
  v.setK("b");
  </code></pre>
  
  <p>As far as I know, this should cause some kind of problem because a map key is supposed to be invariable. What would happen here?</p>
  
  <p>Edit: Consider the key not to be a String but a mutable object as stated in the coment below.</p>