开发者

Java: Generic Type type mismatch syntax error

I have this declaration/initiation written for Java JDK 1.6

Map<String, <? extends List<?>>> groupThemTogether = new HashMap<String, ArrayList<String[]>>();

The error happens at the f开发者_开发技巧irst comma. The error message is

Type mismatch: cannot convert from HashMap<String,ArrayList<String[]>> to Map<String,List>

Why doesn't this compile?


You've got too many angle brackets. Try this:

Map<String, ? extends List<?>> groupThemTogether = new HashMap<String, ArrayList<String[]>>();

This compiles for me.


Are you sure of this?

This, similar code, compiles OK for me:

Map<String, ? extends List<?>> groupThemTogether = new HashMap<String, ArrayList<String[]>>();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜