Friday, 15 September 2017

Java Scope of a for Statement’s Control Variable

Cited from the Book Java How to Program

If the initialization expression in the for header declares the control variable (i.e., the control variable’s type is specified before the variable name, as in

 'for ( int counter = 1; counter <= 10; counter++ )' ,

the control variable (for example, 'counter') can be used only in that for statement—it will not exist outside it.

No comments:

Post a Comment