Thursday, September 10, 2015

do ....... while Repetition Statement in java

The do…while repetition statement is similar to the while statement. In the while, the
program tests the loop-continuation condition at the beginning of the loop, before executing
the loop’s body; if the condition is false, the body never executes. The do…while statement
tests the loop-continuation condition after executing the loop’s body; therefore, the
body always executes at least once. When a do…while statement terminates, execution continues
with the next statement in sequence.



public class Apples {

 public static void main(String[] args){
  int counter = 1 ;
  do
  {
  System.out.printf("%d" , counter );//we will notice it will print 1  

  counter ++;
   System.out.println(); // printing empty line
  }while(counter <=10);

 }
}


1 comment:

  1. xD nice and short class today !!!! But still interesting !!

    ReplyDelete