title: Why doesn't ArrayList.contains(Object.class) work for finding instances types?
body: <p>Say I have an ArrayList which is populated with objects of different types...</p>
  
  <pre><code>ArrayList&lt;Fruit&gt; shelf = new ArrayList&lt;Fruit&gt;();
  Apple apple = new Apple();
  Orange orange = new Orange();
  Pear pear = new Pear();
  
  shelf.add(apple);
  shelf.add(orange);
  shelf.add(pear);
  </code></pre>
  
  <p>I want to find out if <code>shelf</code> contains an <code>Orange</code> object. I've tried</p>
  
  <pre><code>shelf.contains(Orange.class)
  </code></pre>
  
  <p>but this doesn't return true. My understanding is that <code>contains</code> makes use of the <code>equals</code> method for object comparison, so I'm not sure why this is the case.</p>
  
  <p>I realise I can simply iterate through the ArrayList and check the type of the objects individually, but I'm curious as to why <code>contains</code> doesn't behave the way I expect it to.</p>