While Loop

In this section you will learn how to use of while loop statement in java.

While Loop


Loop is the control statement of any language in which whenever you want to perform the repetitious work then you use the Loop control statement. There are mainly three types of loops. Loop repeats a statement or a process multiple times according to the specified conditions. It allows the multiple statements or process to be run for the specified time or it also follows the certain conditions. Loop makes your program readable, flexible and reliable.

While loop: While loop checks the certain condition first, if the condition is true then all the statements or processes written under the while loop are executed otherwise ignored all.

The Syntax for the while loop:

In this program you will see how to use the while loop statement. This program take the value of variable n and generate the table of that number which is 2.

Here is a code of program:- 

public class table{
  public static void main(String[] args){
 int n = 2;
  int i = 1;
  System.out.println("The table of "+n+= ");
  int t = n * i;

Download this example.

Share on Google+Share on Google+

While Loop

Posted on: June 7, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: While Loop   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
September 14, 2011

what's the output..?
samridhi bangwal
October 22, 2011
computer applications

very nice
August 2, 2012
good explanation

i like the explanation