Compapppptbyharshitkochar
Compapppptbyharshitkochar
Harshit kochar
Introduction
The iteration system allows a set of instructions to be
performed repeatedly until a certain condition is
fulfilled . The iteration statements are also called
loops or looping statements .Java provides three kinds
of loops :
For loop
While loop
Do-while loop
For loop
The for loop is the easiest to understand of the java
loops . All its elements are gathered in one place
.Syntax of for loop :
for(initialization expression(s);test-expression;
update expression(s) )
Body-of-the-loop;
While loop
The second loop available in java is while loop .
The syntax of a while loop is:
while(expression)
loop –body
where loop body may contain a single statement , a
compound statement or an empty statement .
Do –while loop
Unlike for and while loops ,the do-while evaluates its
test-expression at the bottom of the loop after excuting
its loop-body statements .
Syntax of a do-while loop is :
do{
statement ;
}
while(test-expression) ;
Thank you