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[]>>();
精彩评论