使用比较器调试程序

时间:2014-08-18 02:23:47

标签: java debugging comparator

我无法调试以下内容。我创建了一个名为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); 
    }
} 

0 个答案:

没有答案