Reference

Loops

The for Loop

  for(initialiser; loop condition; incrementor)
  {
    statements;
  }

Example

  for(int i=0; i<4; i++)
  {
    System.out.println(i + ", ");
  }

The While Loop

  while(condition)
  {
    statements;
  }

Example,

  while(int j < 10)
  {
    System.out.println(j);
    j++;
  }

The Do Loop

  do
  {
    statements;
  } while(condition)

Example,

  int j=0;
  do
  {
    j++;
    System.out.println(j);
  } while(j<10);