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>
精彩评论