title: calling containsKey on a hashmap with custom class
body: <p>I have a Color class that I'm putting in the hashmap. I'd like to call <code>containsKey</code> on the hashmap to ensure whether the object is already present in the hashmap</p>
  
  <p>Color class</p>
  
  <pre><code>public class Color {
    public String name;
    Color (String name) {this.name = name;}
    //getters setters for name 
  }
  </code></pre>
  
  <p>HashMap</p>
  
  <pre><code>HashMap&lt;Color, List&lt;String&gt;&gt; m = new HashMap&lt;Color, List&lt;String&gt;&gt;();
  Color c = new Color("red");
  m.put(c, new ArrayList&lt;String&gt;());
  Color c1 = new Color("red");
  System.out.println(m.containsKey(c1)); //I'd like to return this as true
  </code></pre>
  
  <p>Since <code>c1</code> has <code>name</code> red. I'd like the <code>System.out</code> to return true because the key already present in the map, <code>c</code>, has <code>name</code> red</p>
  
  <p>How can this be achieved?</p>