As your book says, the variable is scoped inside the loop's block, and isn't visible outside it.
Your code won't compile unless there is a different variable var
outside the loop's scope. If there is, then the final statement would use that, not the one in the loop which is now out of scope.