views:

61

answers:

1

Is there anyway to use a bounded wildcard require a class implement more than one interface?

In otherwords, something like...

class Foo<S extends Comparable && Clonable>

...which would require that objects extend both interfaces?

I realize I can make another ComparableAndClonable which extends the two but I don't have control over some of the code (So I can't go make my future-S object implement ComparableAndClonable).

+2  A: 
class Foo<S extends Comparable & Clonable>

Should work.

See this answer for further info.

Strawberry
Aw, FGIW-ed me. Nice.
Lord Torgamus
Thanks, that indeed works.
Pace