Hi AdminRemember that Double objects are immutable. Therefore, the first call to forEach does not change the elements in the original list on which the stream is based. It only replaces the elements of that stream with new ones.
Sorry, but isn't this an issue about java being pass by value? Isn't the argument that the lambda uses a copy of a reference, analogous to how references work when passed to, and inside of, a method such that if you do
Code: Select all
Integer i = 10;
foo(i);
Code: Select all
void foo(Integer i){
i=10;
}
Thank you in advance.