Java Program using while loop…

While loop

This is entry control loop.
Syntax:
While(condition)
{
Statements;
}
Example:
class While
{
  public static void main(String args [])
  {
    int n=10;
    while(n>0)
    {
       System.out.println(“Tick ” + n);
       n–;
    }
  }
}
Output:
D:java >java While
Tick 10
Tick 9
Tick 8
Tick 7
Tick 6
Tick 5
Tick 4
Tick 3
Tick 2
Tick 1

Add Comment