我最近在Eclipse(MAC)上安装了JDK 8,并试图使用这些流。无法在Eclipse上获取流工作
然而,似乎是Java的8配置不正确,因为我得到以下行的代码以下错误:
List<Eshop> tempShops = eshops.stream().filter(e -> e.getName().equals(name)).collect(Collectors.toList());
Multiple markers at this line
- e cannot be resolved to a variable
- e cannot be resolved
- Syntax error on token "-", --
expected
任何人有一个想法是什么可能是错误的?
编辑 也试过像
List<Eshop> tempShops = eshops.stream().filter((e) -> e.getName().equals(name)).collect(Collectors.toList());
看起来像你正在使用'args - >表达式'。它应该是'(args) - >表达式'。 –
嗨,你可以更具体吗? (args)是什么意思?你能给个例子吗? – panipsilos
就像在你的lambda参数中需要括号一样。参见[Java Lambdas简介](/ documentation/java/91/lambda-expressions/2353/introduction-to-java-lambdas)。 –