title: Java util hashmap containsKey()
body: <p>I have been having some trouble using the function containsKey. I wrote a small program to show where I am expecting containsKey to give me a different result: </p>
  
  <pre><code>HashMap&lt;IdentifierInterface, Set&lt;NaturalNumberInterface&gt;&gt; hashMap;
  HashMap&lt;StringBuffer, Integer&gt; works;
  
  TryHashmap(){
      hashMap = new HashMap&lt;IdentifierInterface, Set&lt;NaturalNumberInterface&gt;&gt;();
      works = new HashMap&lt;StringBuffer, Integer&gt;();
  }
  private void start() {      
      Identifier iden = new Identifier('a');
      NaturalNumber nn = new NaturalNumber('8');
      Set&lt;NaturalNumberInterface&gt; set = new Set&lt;NaturalNumberInterface&gt;();
      set.insert(nn);
  
      hashMap.put(iden, set);
      System.out.println(hashMap.containsKey(iden));
  
      Identifier newIden = new Identifier('a');
      System.out.println(hashMap.containsKey(newIden)); //TODO why is this not true?
  
      iden.init('g');
      System.out.println(hashMap.containsKey(iden));
  }
  
  public static void main(String[] argv) {
      new TryHashmap().start();
  }
  </code></pre>
  
  <p>The constructor of the Identifier class is as follows, the init() is similar but it will remove anything that was in the identifier before.</p>
  
  <pre><code>Identifier(char c){
      iden = new StringBuffer();
      iden.append(c);
  }
  </code></pre>
  
  <p>I put something into the hashmap using an Identifier as key, but when I try to use an Identifier with a different name but with the same content the containsKey function returns false where I am expecting a true.
  (the output prints true
  false
  true)</p>
  
  <p>Thanks in advance! </p>