Java 错误-无法推断类型变量K,V-OpenJDK 1.8与ECJ 1.8与lambdas的差异?
我有以下代码:Java 错误-无法推断类型变量K,V-OpenJDK 1.8与ECJ 1.8与lambdas的差异?,java,eclipse,lambda,ecj,Java,Eclipse,Lambda,Ecj,我有以下代码: Type a; List<Pair<Consumer<LocalDate>, LocalDate>> list = new LinkedList<>(); a.getListB().stream().forEach((TypeB b) -> { list.add(new Pair<>(b::setDate, b.getDate())); }); 项目符合性设置为1.8 版本: Openjdk 1.8.
Type a;
List<Pair<Consumer<LocalDate>, LocalDate>> list = new LinkedList<>();
a.getListB().stream().forEach((TypeB b) -> {
list.add(new Pair<>(b::setDate, b.getDate()));
});
项目符合性设置为1.8
版本:
Openjdk 1.8.0-191Eclipse 4.10
这是ECJ错误吗?Eclipse4.10落后于7个版本,Java8更新191也相当陈旧。请不要浪费时间使用过时的软件。不要使用
forEach
建立列表。改用.collect(toList())
。
Type a;
List<Pair<Consumer<LocalDate>, LocalDate>> list = new LinkedList<>();
a.getListB().stream().forEach(b -> list.add(new Pair<>(b::setDate, b.getDate())));
[ERROR] reason: cannot infer type-variable(s) K,V
[ERROR] (argument mismatch; java.lang.Object is not a functional interface)