Skip to content
Advertisement

Trying to update a CompletableFuture variable but get error : local variables referenced from a lambda expression must be final or effectively final

JavaScript

I was trying to update the result in the forloop in description(), since result.thenApply() results in a new CompletableFuture instance, I need to reassign it to a new variable in order to update result, but i am not very sure how

Advertisement

Answer

You don’t need to reassign it to a new variable, and you shouldn’t. Combine the futures instead.

JavaScript
Advertisement