Loops in Java-while,for, do while

Loops are used to execute a set of instructions repeatedly when some conditions become true.

loops can be controlled two ways

Entry Controlled Loop
Exit Controlled Loop

Loop, where test condition is checked before entering the loop body, known as Entry Controlled Loop.

Example: while loop, for loop

Loop, where test condition is checked after executing the loop body, known as Exit Controlled Loop.

Example: do while loop

There are three types of loops in java.

1)for loop

Syntax:

for (initialization ; testing condition; increment/decrement)
{
statement(s)
}

2)while loop

syntax:

initialization
while (boolean condition)
{
loop statements…
}

3)do-while loop

Syntax:
initialization
do
{
statements..
}
while (condition);

Other important posts links ::