Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

While-loop

While loop
-is a statement or block of statements that is repeated as long as some condition is satisfied.

while loop has the form:

while( boolean_expression )
{
statement1;
statement2; . . .
}

-The statements inside the while loop are executed as long as the boolean_expression evaluates to true.

Example 1
int x = 0;
while (x
Example 2
//infinite loop
while(true)
System.out.println(“hello”);

Example 3

//no loops
// statement is not even executed
while (false)
System.out.println(“hello”);


This post first appeared on Java Programs, please read the originial post: here

Share the post

While-loop

×

Subscribe to Java Programs

Get updates delivered right to your inbox!

Thank you for your subscription

×