Home Java Beginners While Loop



While Loop
Posted on: June 7, 2007 at 12:00 AM
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:
  while(condition)
  {
  statements;
   }

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+= ");
  while(i<=10)
  {
  int t = n * i;
  System.out.println(t);
  i++;
  }
  }
}

Download this example.

Related Tags for While Loop:
cflexoopormantprocessformtimeloopslanguagecontroliotypesmultiplemaketypeloopipstatereadaiooifconditionforieworkadaprogramstatementlextoramrunxibcilanprocwsemainitmultilsliuseulpeimceinrmrepeatstaconditionsmntpstrwanoopsadesspecemallagemehrprostatementsrelwhenwhichsreliabletipspsoeeessatanykisimellfollowflexibleeaandarstatccreadablertwantwheneverxissrocrdthcondcerstabablexilsoiplpleplprocesprndonogrolonl


More Tutorials from this section

Ask Questions?    Discuss: While Loop   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.