public ClassA
{
private String firstId;
private String secondId;
public void setFirstId(String firstId) {
this.firstId = firstId;
}
public String
You can implement a compareTo(ClassB) or even a compareTo(CommonInterfaceOrSuperclass) method in each that will do the field-level comparison and return true if they meet your comparison criteria. You would then need to iterate over your lists and check against each element.
Another alternative is to implement the equals()/hashcode() pair, which would, when coded properly, allow your List to find and compare for equals-ness successfully. Your contains() test would then work.