tags:

views:

100

answers:

3

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.

+6  A: 
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.

bmargulies
+2  A: 
class A<E extends MyInterface>
{

}

That's it, quite simple..

Jack
A: 

Let E be the type of your interface myInterface

stacker