title: Java Remove common elements between 2 ArrayList of objects
body: <p>I have a Java class as</p>
  
  <pre><code>class Students{
      private String fName;   
      private String lName;
      private String uName;
  
  
      public Students(String fName, String lName, String uName) {
              this.fName = fName;
              this.lName = lName;
              this.uName = uName;
       }      
  
      public String getuName() {
          return uName;
      }
      public void setuName(String uName) {
          this.uName = uName;
      }
      public String getfName() {
          return fName;
      }
      public void setfName(String fName) {
          this.fName = fName;
      }
      public String getlName() {
          return lName;
      }
      public void setlName(String lName) {
          this.lName = lName;
      }
  
  }
  </code></pre>
  
  <p>Also I call this using</p>
  
  <pre><code>public class TestClass {
  public static void main(String[] args) {
  
      Students students1 = new Students("xyz","abc","xyzAbc");
      Students students2 = new Students("poi","son","poison");
      Students students3 = new Students("yog","jos","yogjos");
  
      Students students4 = new Students("xyz","abc","xyzAbc");
      Students students5 = new Students("pon","son","xyzAbc");
      Students students6 = new Students("yog","jos","someotherUName");
      Students students7 = new Students("yog","jos","someotherUName2");
  
      List studentList1 = new ArrayList();
      List studentList2 = new ArrayList();
  
      studentList1.add(students1);
      studentList1.add(students2);
      studentList1.add(students3);
  
      studentList2.add(students4);
      studentList2.add(students5);
      studentList2.add(students6);
  }
  }
  </code></pre>
  
  <p>Now I want a filtered list which would contain only unique "uName" values.
  Thus I want the comparision between "uName" field of each list and remove common ones. </p>
  
  <p>At the end I would want 2 filetered list for studentList1 and studentList2.</p>
  
  <p>I read about the removeAll method, but it seems to work with List of Integer/String data and not with List of Objects (as in my case).</p>
  
  <p>Please suggest.</p>