编译下面的代码时,出现以下错误:
PersonalInformation 不是抽象的,不会覆盖 Comparable 中的抽象方法 compareTo(Object)
我认为这意味着我的compareTo
方法有问题。但一切似乎都很好。有人有建议吗?
import java.util.*;
public class PersonalInformation implements Comparable
{
private String givenName;
private String middleInitial;
private String surname;
private String gender;
private String emailAddress;
private String nationalId;
private String telephoneNum;
private String birthday;
public PersonalInformation(String gN, String mI,
String sur, String gen, String eMa, String natId,
String teleNum, String birthd)
{
givenName = gN;
middleInitial = mI;
surname = sur;
gender = gen;
emailAddress = eMa;
nationalId = natId;
telephoneNum = teleNum;
birthday = birthd;
}
public int compareTo(PersonalInformation pi)
{
return (this.gender).compareTo(pi.gender);
}
}