...
This noncompliant code example shows a variable that is declared outside the for
loop. Reusability is reduced because the value of the loop index, i
, is modified by the for
statement. Suppose, for example, this code snippet is copied and pasted with the intent to use a different index, j
. If the index-variable change were omitted, the new loop would then attempt to iterate over index i
. Unexpected behavior can follow because i
remains in scope.
...