title: List.contains() fails while .equals() works
body: <p>I have an <code>ArrayList</code> of <code>Test</code> objects, which use a string as the equivalency check. I want to be able to use <code>List.contains()</code> to check whether or not the list contains an object that uses a certain string.</p>
  
  <p>Simply:</p>
  
  <pre><code>Test a = new Test("a");
  a.equals("a"); // True
  
  List&lt;Test&gt; test = new ArrayList&lt;Test&gt;();
  test.add(a);
  test.contains("a"); // False!
  </code></pre>
  
  <p>Equals and Hash function:</p>
  
  <pre><code>@Override
  public boolean equals(Object o) {
      if (o == null) return false;
      if (o == this) return true;
      if (!(o instanceof Test)) {
          return (o instanceof String) &amp;&amp; (name.equals(o));
      }
      Test t = (Test)o;
      return name.equals(t.GetName());
  }
  
  @Override
  public int hashCode() {
      return name.hashCode();
  }
  </code></pre>
  
  <p>I read that to make sure <code>contains</code> works for a custom class, it needs to override <code>equals</code>. Thus it's super strange to me that while <code>equals</code> returns true, <code>contains</code> returns false.</p>
  
  <p>How can I make this work?</p>
  
  <p><a href="http://ideone.com/sXC06t">Full code</a></p>