March 2019
Intermediate to advanced
242 pages
6h 21m
English
As of now, it isn't clear whether a lambda expression will be able to access the value of the enclosing variable, which is overshadowed by the lambda parameter; and if it can, how?
For example, let's modify the preceding code by replacing the call to the toUppercase() method with a call to the concat() method as follows (changes are in bold):
1. String key = "Docker"; // local variable key2. talks.stream()3. .map(key -> key.concat(key)) 4. .forEach(System.out::prinltn);
In the preceding code, imagine that the lambda expression on line 3 needs to access the value of the key variable defined on line 1, since it wants to pass it to the concat() method. As of right now, it hasn't been finalized whether this will be allowed. ...
Read now
Unlock full access