Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 错误-无法推断类型变量K,V-OpenJDK 1.8与ECJ 1.8与lambdas的差异?_Java_Eclipse_Lambda_Ecj - Fatal编程技术网

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-191
Eclipse 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)