Scoping out the counter variable in for loop - Java Language Basics

Java examples for Language Basics:for

Description

Scoping out the counter variable in for loop

Demo Code

public class Main{
  public static void main(String[] args){
    int i;/* ww w  .  j a v  a2s .c  o m*/
    for (i = 1; i <=10; i++)
      System.out.println(i);
    System.out.println("The final value of i is " + i);
  }
}

Related Tutorials