Launch your tech mastery with us—your coding journey starts now!
Course Content
Array Handling
0/1
String Handling
0/1
Wrapper Classes
0/1
Collections in Java
0/1
Packages
0/1
File Handling
0/1
Multithreading
0/1
Java Networking
0/1
Core Java

Java programming language provides the following types of loop to handle looping requirements. 

Sr.No.

Loop & Description

1

while loop

Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body.

The syntax of a while loop is −

while(condition) {

   // Statements

}

2

for loop

Execute a sequence of statements multiple times and abbreviates the code that manages the loop variable.

for(initialization; condition; update) {

   // Statements

}

3

do…while loop

Like a while statement, except that it tests the condition at the end of the loop body.

do {

   // Statements

}while(condition);

Loop Control Statements

Loop control statements change execution from its normal sequence. When execution leaves a scope, all automatic objects that were created in that scope are destroyed.  Java supports the following control statements. 

Sr.No.

Control Statement & Description

1

break statement

Terminates the loop or switch statement and transfers execution to the statement immediately following the loop or switch.

The syntax of a break is a single statement inside any loop −

break;

2

continue statement

Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.

The syntax of a continue is a single statement inside any loop −

continue;

Watch on YouTube