Why can't I do this in Java:
interface Context{
void add(Integer o);
}
class Subclass implements Context{
@Override
public void add(Object o){...}
}
Wouldn't Subclass.add already implement Context.add since it add(Object) can perform everything add(Integer) can?
What is a good way around this?
Right now I am doing a kind of ugly way:
private void actuallyAdd(Object o){...}
public void add(Object o){actuallyAdd(o);}
public void add(Integer o){actuallyAdd(o);}
EDIT: this is not a duplicate of above question. In the given question, the superclass is the one that has a more general 'Object' as the parameter, while the subclass is more specific. This doesn't work as a more specific method may not be able to handle any Object. In my question the subclass is less specific than the superclass, meaning the subclass is always able to handle whatever the superclass requires.