...
Declare all enhanced for
statement loop variables final. The final
declaration causes Java compilers to flag and reject any assignments made to the loop variable.
...
Compliant Solution
Declaring i
to be final mitigates this problem by causing the compiler to fail to permit i
to be assigned a new value:
...