Al Wld Al Wld - 1 year ago 101
Java Question

Nested generic subtyping

I am trying to do something like this:

public class MyClass <T extends AbstractClass<K extends ConcreteClass>>

I get an
Unexpected bound
error for K extends GenericJson, and I am not sure why.

Any help would be appreciated.


Answer Source

The syntax to use is just a little different:

public class MyClass <K extends ConcreteClass, T extends AbstractClass<K>>

Or, if you don't care about K:

public class MyClass <T extends AbstractClass<? extends ConcreteClass>>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download