Remove whats common to both lists
<p>How can I remove whats common to both lists based on an object attribute. Below I am trying to remove all values from testList2 that contain the same str1 parameter as testList1.</p>

<p>I think I can override the equals method in the class that is being compared as equals method is used under the hood when using removeAll ?</p>

<p>testList1 &amp; testList2 are of type ArrayList and both contain a List of Test objects.</p>

<pre><code>testList1.removeAll(testList2);

public class Test{

    private String str1;
    private String str2;

    public Test(String str1 , String str2){
        this.str1 = str1;
        this.str2 = str2;
    }

    public String getStr1() {
        return str1;
    }

    public String getStr2() {
        return str2;
    }

    public boolean equals(Object o){

        Test t = (Test)o;
        return this.getStr1().equalsIgnoreCase(t.getStr2());

    }
}
</code></pre>
