title: comparison of two Arraylist and Create new Arraylist
body: <p>I have two ArrayList a &amp; b both ArrayList size is more then 50000. I want to compare them and remove ArrayList b from a and Add Remaining object into new ArrayList c.</p>
  
  <p>My Code is Here : </p>
  
  <pre><code>c = new ArrayList&lt;String&gt;(a);
  c.removeAll(b);
  </code></pre>
  
  <p>and i am also try this code </p>
  
  <pre><code>for (int i = 0; i &lt; a.size(); i++) {
      if (!b.contains(a.get(i))) {
          c.add(a.get(i));
      }
  }
  </code></pre>
  
  <p>both comparison process is taking lot of time.</p>
  
  <p>How to solve and optimize this problem.</p>