Java how to use stream map to return boolean [duplicate]
问题 This question already has an answer here : Java8 Effectively Final compile time error on non final variable (1 answer) Closed 3 years ago . I am trying to return a boolean for the result. public boolean status(List<String> myArray) { boolean statusOk = false; myArray.stream().forEach(item -> { helpFunction(item).map ( x -> { statusOk = x.status(); // x.status() returns a boolean if (x.status()) { return true; } return false; }); }); } It's complaining variable used in lambda expression should