Obj1 x = null;
String key = null;
while(it.hasNext()){
x = it.next();
key = x.getKey();
listObject.stream().filter(e -> e.getKey().equals(key)).findFirst().get();
}
This is complaining with the following message: "Local variable key must be final or effective final..." I understand the the lambda context is created at runtime and it needs variables that do not change.
How can I use the functional style to find the object in the list?
I want to avoid the old fashion way of iterating over the list with while.