Java Reference
In-Depth Information
• It is more effective than using the set of nested if statement.
Iteration statements
These statements are used to create loop. There are three types of iteration statement used
in java.
While statement
Its function is to repeat or block statement while its controlling expression is true.
While (condition) {
// body of loop
The loop is executed when the condition is true. When it is false the control will pass to the
next line of the code following the loop.
For example
Class while {
Public static void main (string args [])
Int n = 5;
While (n>0)
System.out.println (“tick “+ n);
It will tick 5 times
Tick 5
Search WWH ::

Custom Search