D
dwelzel
I've been having some trouble with generic methods and inheritance.
Suppose I have an interface that looks like:
interface A {
public <T extends MyClass> void foo(T input);
}
class MyClassDerivative extends MyClass { ... }
Finally:
class B implements A {
public void foo(MyClassDerivative input);
}
-----------------------
This doesn't work and I'm wonder if it is possible to express this idea
using generics. In the interface I want to say, you need to define a
method which takes this type, or a derivative of it and not force
derived classes into casting into their derived type.
Suppose I have an interface that looks like:
interface A {
public <T extends MyClass> void foo(T input);
}
class MyClassDerivative extends MyClass { ... }
Finally:
class B implements A {
public void foo(MyClassDerivative input);
}
-----------------------
This doesn't work and I'm wonder if it is possible to express this idea
using generics. In the interface I want to say, you need to define a
method which takes this type, or a derivative of it and not force
derived classes into casting into their derived type.