So on one level, the answer is "because the rules say so". On another level, why did they write the rules this way? Well, the enhanced for loop is really just a shortcut for a couple very common lops of loops. The enhanced for loop doesn't
have to enable you to do everything that a normal for loop can, because after all you can always go back to using a regular for loop. They just want to support the most common cases here. And the vast majority of the time, there's no
need to declare the variable outside the loop. In fact, often this is just an added potential source of bugs, as it exposes the variable to a larger scope than it really needs, increasing the chance of name collisions or of using the wrong variable name. A good discussion of this can be found in
Effective Java pp. 141-4: Minimize the scope of local variables.