how could I set my object to another in lambda expression? I got error
variable used in lambda expression should be final or effectively final
with following code:
public MyObj myFun(MyObj o) {
MyObj obj = null;
myObjList.stream().filter(o -> ...).forEach(o -> {
// I do some stuff here
// I need here set obj to o, but I got error
obj = o;
});
return myObj; // I need return found obj or null;
}