Given:
What is the result?
Given:
What is the result?
The code will produce a compilation error because variables used in lambda expressions must be final or effectively final. In this case, 's' is modified after the lambda expression is defined, making it not effectively final.
tested
right answer is D Local variables decalred in the enclosing method, including its formal parameters, can be accessed in a lambda expression provided and they are effectively final This one : String s = "Oracle"; Runnable r = () -> { System.out.println(s); }; //s = "Java"; Thread t = new Thread(r); t.start() will be ok
that is ok, variables in lambdas must be a final or effectively final. If s is modified then code not compile
variables in lambdas must be a final or effectively final. If s is modified then code not compile