Counter-controlled repetition with the for repetition statement. - Java Language Basics

Java examples for Language Basics:for

Description

Counter-controlled repetition with the for repetition statement.

Demo Code

public class Main 
{
   public static void main(String[] args) 
   {/*  w  w  w .ja v a 2 s . c  o  m*/
      // for statement header includes initialization,  
      // loop-continuation condition and increment
      for (int counter = 1; counter <= 10; counter++) 
         System.out.printf("%d  ", counter);

      System.out.println();
   }
}

Result


Related Tutorials