I have a class that implements Comparator but not that I need my class to be Serializable How can I implement both of them ?
public class A implements Comparator<A>
{
}
It's a common misconception that Java does not have multiple inheritance. It doesn't have multiple inheritance of state, but it does have multiple inheritance of (declarations of) behavior, which is shown through interfaces. So you can have a single class implement multiple interfaces:
public class A implements Comparator<A>, Serializable {
}
extenda singleclass, but you canimplementunlimited interfaces.