开发者

Java Generics for class objects implementing a specific interface

I am trying to define HashMap< ? , String> where 开发者_如何学运维? is a class object from some implementation of a given interface, P.

For example, for interface ISearchEngine, i want ? to possibly be Google.class, Yahoo.class, Bing.class, etc.


How about

HashMap<Class<? extends ISearchEngine>, String>


I think you want

HashMap<? extends ISearchEngine, String>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜