Search This Blog

Thursday, 29 December 2011

The for Loop with Example


The for loop is the type of  looping construct. It also works as while loop construct but it provide the initialization, condition and the increment  is same written in the for construct. All the statements which has to be executed written in the for block

The Syntax for the For Loop:  
  for( initialization; termination; increment)
  {
  statements;
  }

Example

public class  ForLoop {
  public static void main(String[] args) {
  for(int i = 1;i <= 5;i++) {
  System.out.print(i);
  }
  }
}

No comments:

Post a Comment