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..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.