I've been trying to override a compareTo in such a way: This is the original:
@Override
public int compareTo(ProductPart6 s)
{
return this.getproductName().compareTo(s.getproductName());
}
this is what i'm trying to override it with: it throws an error The method compareTo(SubClass) of type SubClass must override or implement a supertype method.
@Override
public int compareTo(SubClass s)
{
return this.getTitle().compareTo(s.getTitle());
}
I'm thinking this is very wrong. My ProductPart6 doesn't have a getTitle() and that causes it
@Override
public int compareTo(ProductPart6 s)
{
return this.getTitle().compareTo(s.getTitle());
}
to throw an error (getTitle() is undefined for the type ProductPart6) - if I defined it there there'd be no point overriding it. What am I doing wrong? I have the SubClass extending ProductPart6 and ProductPart6 implements Comparable - I thought I could implement it on SubClass, but no. That was a no go.
Comparable
on the super class? – Calvert@Override
? – Gumbotil