编译下面的代码时,我遇到了以下错误:
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);
}
}