[英]Java: Generic Type type mismatch syntax error
I have this declaration/initiation written for Java JDK 1.6我为 Java JDK 1.6 编写了此声明/启动
Map<String, <? extends List<?>>> groupThemTogether = new HashMap<String, ArrayList<String[]>>();
The error happens at the first comma.错误发生在第一个逗号处。 The error message is
错误信息是
Type mismatch: cannot convert from HashMap<String,ArrayList<String[]>> to Map<String,List>
类型不匹配:无法从 HashMap<String,ArrayList<String[]>> 转换为 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:这个类似的代码对我来说编译OK:
Map<String, ? extends List<?>> groupThemTogether = new HashMap<String, ArrayList<String[]>>();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.