Assume you have some objects which have several fields they can be compared by:
public class Person {
private String firstName;
private String lastN
Another option you can always consider is Apache Commons. It provides a lot of options.
import org.apache.commons.lang3.builder.CompareToBuilder;
Ex:
public int compare(Person a, Person b){
return new CompareToBuilder()
.append(a.getName(), b.getName())
.append(a.getAddress(), b.getAddress())
.toComparison();
}