Search This Blog

If you have any problem or question please write in the comments. We will try to solve and send you the solution. Not just that we will also post your problems solution on our blog.

Monday, 27 June 2011

While loop in java

While loop:
                    The while loop is java's most fundamental looping statement. It is very easy and powerful loop of java.It repeats a statement or block while its Boolean expression is true. This Boolean expression controls the loop.

                 while (condition)
                    //body of the loop

The body of the loop will be executed till the conditional expression is true. When conditional expression comes false the control passes to the next statement right after the body of the loop. Always remember, in while loop first of all conditional expression is evaluated if it is true then body of the loop will be executed. If it becomes false at the beginning then body of the loop will not be executed, even once.

Curly braces are not important if you have only one statement to repeat but using curly braces is a good habit. Another point you should know that the body of while loop can be empty.

1 comment:

  1. Hi mates, how is all, and what you want to say regarding this piece of writing, in my view its actually awesome in support
    of me.
    Feel free to visit my web-site ...