Menu
Topics Index
...
`


Control Statements >
Siva Nookala - 14 Mar 2016
Loops repeatedly executes the same set of instructions until a termination condition is met.
We have three loops in Java
for Loop In Java
for(initialization; condition; iteration)
{
}
Working : When the loop first starts, the initialization portion is executed. Next, condition is evaluated. If the condition is true, then the body of the loop is executed.If it is false, the loop terminates. Next, the iteration portion of the loop is executed.

while Loop In Java
While loop is Java's most fundamental loop statement. It repeats a statement or block untill the controlling expression is true.
while(condtion)
{
//body of loop
}
do while Loop In Java
do-while loop is similar to while loop statement but do-while loop executes all the statements in the block, at least once and then checks the condition at the end. If the condition is true then all the statements are re-executed. This checking of the condition and execution of the statements/blocks continues until the condition is false.

do {
// body of loop
} while (condition);

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App