Loop control flow statements in Java allow you to change the normal execution of loops. They help you skip iterations, exit loops early, or control nested loop behavior efficiently.
Loop control statements are typically used inside for, while, or do-while loops to manage execution flow based on conditions.
// Using break and continue in a for loop
for(int i = 1; i <= 5; i++) {
if(i == 3) {
continue;
}
if(i == 5) {
break;
}
System.out.println(i);
}
// Using labeled break to exit outer loop
outer:
for(int i = 1; i <= 3; i++) {
for(int j = 1; j <= 3; j++) {
if(i == 2 && j == 2) {
break outer;
}
System.out.println(i + "," + j);
}
}
The continue statement skips printing when i == 3. The break statement stops the loop completely when i == 5.
Labeled break exits the outer loop directly when the condition is met.
break carefully to avoid unreadable logiccontinue for skipping specific casescontinue in nested loopsbreak into a condition-based loop