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 key
2. 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.
If it is allowed, Java will need to devise a way to mark and clearly differentiate a lambda parameter from another variable with the same name, in the enclosing block. This will be required for code readability—which, as you know, is important.
In the next section, we'll look at how Java is trying to resolve overloaded method calls, which define functional interfaces as parameters.