开发者

Combining bounded wildcards in Java

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开发者_C百科 object implement ComparableAndClonable).


class Foo<S extends Comparable & Clonable>

Should work.

See Java Generics Wildcarding With Multiple Classes for further info.

[1]:

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜