In Java I have the following code
List myList = new ArrayList<>();
for (int i=0;i<9;i++) {
myList.add(i);
}
Integer sum = 0;
m
Not exactly the answer you are looking for, but in most scenarios you won't need to modify that inside the lambda. This is because it's not idiomatic for lambdas to be state-changing in a proper functional style.
What you can do to achieve your result is use any of the higher-level functions provided to mask the "accumulator", and then assign:
sum = myList.stream().mapToInt(x->x).sum();