Java Program To Understand While Loop

      No Comments on Java Program To Understand While Loop

A while loop statement executes a code until the given condition is true.

Syntax:-
while(condition){
   statement(s);
}
Example:-
class scan
{
public static void main(String arg[])
 {
   int i=1;
   while(i<=10)
   {
    System.out.println("Value of i = "+i);
	i++;
   }
 }
}

OUTPUT:-

Value of i = 1
Value of i = 2
Value of i = 3
Value of i = 4
Value of i = 5
Value of i = 6
Value of i = 7
Value of i = 8
Value of i = 9
Value of i = 10

Leave a Reply

Your email address will not be published. Required fields are marked *