Hi everyone.
Welcome back to this tutorial.
In this tutorial we will discuss about the definition of effectively final.
As we have seen in the previous tutorial, it is not allowed to reassign or modify the value of the
local variable inside the lambda expression.
We did not make the variable final, but still inside the lambda body it is treated like a final variable.
This concept is called effectively final.
I have provided the same example here.
Here we have a local variable called int value equal to four.
If you try to change a value here by reassigning it, this will give you the compilation issue.
This concept is called effectively final until Java seven.
If you want to use the variable inside the anonymous class, which is nothing but the implementation
of the functional interface, you have to declare the variable with the final keyword.
Basically, with this change, it saves a keystroke.
What are the advantages of effectively final having the local variables declared as effectively?
Final is going to make the life of the developers easy for building the concurrency applications.
One Another advantage is that this will promote the functional style programming and demotes the imperative
style programming.
With this, we came to the end of this tutorial.
Thank you for watching.