title: Check if an ArrayList contains a given object
body: <p>Assuming I have class like this:</p>
  
  <pre><code>class A {
    int elementA;
    int elementB
  }
  </code></pre>
  
  <p>I also have an <code>ArrayList</code> like this: <code>ArrayList&lt;A&gt; listObj</code>.</p>
  
  <p>How can I check if that list contains an object using only some of the  properties of <code>A</code>? E.g. considering only <code>elementA</code> for finding if object <code>newA{elementA}</code> is already in the list?</p>
  
  <p>For object <code>A</code> I have defined an <code>equals</code> method, where I consider only the <code>elementA</code>, however this is not enough. </p>