title: Comparing two object arraylists
body: <p>First time here so I hope this makes sense!</p>
  
  <p>I have two object arrays say  l1 and  l2, I want to run a compare between these two lists and get a the unmatched value in say in  l3. 
  User class contains 2 Strings:</p>
  
  <pre><code>userEnteredValue 
  valueReturnedFromDatabase
  </code></pre>
  
  <p>Say, l1 contains: Java, JSF, JAXR, foo
  l2 contains: JSF, JAXR</p>
  
  <p>I could run a compare for matching values, but for not for non-matching values. The logic seems to be flawed. Any help?</p>
  
  <p>For matching values:</p>
  
  <pre><code>for(User u1 : l1) {
     for(User u2: l2) { 
        if(u1.getUserEnteredValue().equals(u2.getValueReturnedFromDatabase())) {
          l3.add(u1);
        }
  } 
  </code></pre>
  
  <p>But, for the non-matching when I say not equal to, instead of getting only the unique values I get all values. 
  A couple of similar posts on Stackoverflow suggest to implement the equals and hashcode method in the User class. Is this necessary, since my arraylist size don't go beyond 5 to 10.</p>