开发者

Combining bounded wildcards in Java

开发者 https://www.devze.com 2022-12-21 16:54 出处:网络
Is there anyway to use a bounded wildcard require a class implement more than one interface? In otherwords, something like...

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

精彩评论

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