title: How to compare two arraylist?
body: <p>I have two <code>ArrayList</code>. Each is of size 100000. I want to compare them and count matched elements.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>for (int i = 0; i &lt; mArryLst2.size(); i++) {
     if (ArryLst1.contains(mArryLst2.get(i))) {
         matchedPixels++;         
     }
  }
  </code></pre>
  
  <p>Here comparison process is taking lot of time.</p>
  
  <p>How to solve and optimize this problem.</p>