开发者

How to restrict types which are allowed as "T" in a generic class?

开发者 https://www.devze.com 2023-01-07 20:22 出处:网络
开发者_开发技巧I\'ve got a class Foo<T>. How can I say that I want T to be some class implementing BarInterface? Writing simply class Foo<T implements BarInterface> doesn\'t compile.Use ex
开发者_开发技巧

I've got a class Foo<T>. How can I say that I want T to be some class implementing BarInterface? Writing simply class Foo<T implements BarInterface> doesn't compile.


Use extends instead of implements.

0

精彩评论

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