The break Keyword in Java

The break keyword is utilized to stop the whole loop execution. The break word must be utilized inside any loop or a switch construct. The break keyword will stop the execution of the deepest circle and begin executing the following line of code after the ending curly bracket. The syntax for using this keyword is as follows:

break;

Sample Implementation:

public class myTest {

public static void main(string args[]) {

int [] mynumbers = {0, 5, 10, 15, 20};

for(int i : mynumbers ) {

if( i == 15 ) {

break;

}

System.out.print( i );

System.out.print(ā€œ\nā€);

}

}

This would deliver the accompanying result:0
5
10