It gives these errors
The type Email must implement the inherited abstract method Comparable.compareTo(Object)
The type Email.DateComparator must implement the inherited abstract method Comparator.compare(Object, Object)
The type Email.SubjectComparator must implement the inherited abstract method Comparator.compare(Object, Object)
although I have
public class Email implements Comparable, Serializable
{
...
public static class DateComparator implements Comparator
{
public int compare(Email email1, Email email2)
{
return email1.getTimestamp().compareTo(email2.getTimestamp());
}
}
public static class SubjectComparator implements Comparator
{
public int compare(Email email1, Email email2)
{
return email1.getSubject().compareTo(email2.getSubject());
}
}
}
How to fix?
Implement the Comparator.compare(Object, Object) method. Cast the arguments to Email. You implemented Comparator.compare(Email, Email)