我无法调试以下内容。我创建了一个名为Person
的对象,然而,比较器不起作用:
//HERE IS THE OBJECT THE COMPARATOR IS REFERRING TO
public class Person {
String firstname;
String lastname;
int z;
public Person(String l, String m, int e)
{
firstname=l; lastname=m; z=e;
}
}
// COMPARATOR BEGINS HERE
public class CustomComparator implements Comparator<Person> {
public int compare(Person object1, Person object2)
{
@Override
return object1.firstname.compareTo(object2.firstname);
}
}