It is one of the most important statements is the break statement in java and let’s see how to use the java break label.break is used to break or terminate a loop whenever we want.Just type break; after the statement after which you want to break the loop.
class Test {
public static void main(String[] args) {
// for loop
for (int i = 1; i <= 10; ++i) {
// if the value of i is 5 the loop terminates
if (i == 5) {
break;
}
System.out.println(i);
}
}
}