开发者

Java: Generic Type type mismatch syntax error

开发者 https://www.devze.com 2023-03-20 08:59 出处:网络
I have this declaration/initiation written for Java JDK 1.6 Map<String, <? extends List<?>>> groupThemTogether = new HashMap<String, ArrayList<String[]>>();

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

精彩评论

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

关注公众号