Java Break Statement :
Whether the loop condition is true or false, the break statement is used to end a loop early. When a loop contains a break statement, the loop is instantly stopped, and program control shifts to the statement that follows the break.
/*** Java Break Example*/public class JavaExample {public static void main(String[] args) {for(int i=0;i<=10;i++){if (i==5){System.out.println("Loop Break Here: " +i);break;}System.out.println("Loop index : " +i);}}}
Output:
Loop index : 0
Loop index : 1
Loop index : 2
Loop index : 3
Loop index : 4
Loop Break Here: 5