Page 197 - CA_Blue( J )_Class9
P. 197
The two categories are as follows:
Categories of Loop
Entry Control Loop Exit Control Loop
• Entry Control Loop: If the testing condition is checked before executing the body of the loop, then it is called
entry controlled loop.
• Exit Control Loop: If the test condition is checked after executing the body of the loop, then it is called exit
controlled loop.
9.2.1 Types of Loops
Java uses three types of loops. Let us take a look at them.
Types of Loops
for loop while loop do while loop
Let us learn about these loops one by one.
9.2.2 The for Loop
The for loop in Java executes a set of statements repeatedly for a fixed number of times. This loop is used when
the user knows how many times the loop will execute.
The syntax of for loop is:
for (initialization; condition for testing; increment or decrement)
{
//body of the loop
}
Start
Initialisation
false Conditional
Expression
true Increment/Decrement
Body of for loop
Stop
Note: If the body of a loop contains only one statement, braces can be omitted. However, if there are
multiple statements, braces are required; otherwise, Java will report an error.
Iterative Constructs in Java 195

