Example:
for (int i = 0; i < 10; i++) {
System.out.println(i * i);
}
// System.out.println("value of i = " + i);
// ERROR! i is not visible
However, when using the for loop the following is recommended:
Example: Calculate and print the first 10 powers of 2.
int i, powOf2;
for (i = 0, powOf2 = 1; i < 10; i++, powOf2 *= 2)
System.out.println("2 to the " + i + " = " + powOf2);