I want to have a generic object that implements an interface. I mean if i have a class A
class A<E> {
E x;
}
I want to make sure that x will implement a particular interface(myInterface). In other words, that the type E implements an interface.
class A<E extends MyInterface> {
E x;
}
I initially thought you were looking for:
class A<E> implements MyInterface {
E x;
}
or
class A<E> implements MyInterface<E> {
E x;
}
as appropriate.
class A<E extends MyInterface>
{
}
That's it, quite simple..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With