title: Error comparing two ArrayLists in java
body: <p>I'm trying to write a method that takes 2 ArrayLists of doubles and returns all the values in set1 that aren't found in set2. These numbers should be returned in set3. I keep getting an out of memory error. Can anyone point me in the right direction?</p>
  
  <pre><code>ArrayList&lt;Double&gt; setDiff(ArrayList&lt;Double&gt; set1, ArrayList&lt;Double&gt; set2){
      ArrayList&lt;Double&gt; set3 = new ArrayList&lt;Double&gt;();
      int count = 0;
      while(count &lt; set1.size()){
          boolean inList = false;
          while(inList == false){
              int count2 = 0;
              while(count2 &lt; set2.size() &amp;&amp; set1.get(count) == set2.get(count2)){
                  count2++;
              }
              if(count2 != set2.size()){
                  set3.add(set1.get(count));
              }
              else{
                  inList = true;
                  count++;
              }
          }
      }
  
      return set3;
  }
  </code></pre>