Given:
Which is true?
Given:
Which is true?
The code does not compile because lambda expressions in Java can only capture variables that are final or effectively final. In this code, the variable 'i' is modified by the 'i++' statement after it is assigned to the lambda expression, making it no longer effectively final. As a result, this causes a compilation error.
variables in lamba must be effectively final or final, whhen i is modified i++, compilation error is show.
error: local variables referenced from a lambda expression must be final or effectively final
B is correct
Answer is B. lambda expressions work with final variables, as well as effectively final variables. The moment you do something like i++ the variable i will be no longer treated as final