In this case, final Books books
simply means that books
must be assigned a value exactly once.
I like to use the final
keyword like this as it shows intent of the variable, which I find to be valuable information when looking at code as it removes yet another variable from the situation...so to speak.
If I don't mark a variable as final
then it stands out as something to keep my eye on because it's going to change values sometime soon. This information is helpful while, for example, stepping through the code in the debugger or refactoring & moving around code.
- For further reading on all things
final
: The Final Word On the final Keyword