Break Statement
Thebreak statement is used to jump out of a loop or a switch statement.for (int i = 0; i < 10; i++) {
if (i == 4) {
break; // Stops the loop when i is 4
}
System.out.println(i);
}
Learn how to use the break statement to exit loops and switch statements prematurely.
break statement is used to jump out of a loop or a switch statement.for (int i = 0; i < 10; i++) {
if (i == 4) {
break; // Stops the loop when i is 4
}
System.out.println(i);
}