Core Java SQL Oracle PHP Examples JSP JDBC MORE

Java Break statement


To break the loop execution Java break statement is used.

It is used to break loop , switch statement and Label blocked.

If we write a break statement inside a loop, the loop is immediately stop and the program resumes at the next statement following the loop.

If we used in inner loop, then it breaks only inner loop.

Syntax:

jump-statement;
    break;

Example

class Break statement Example {
public static void main(String[] args) {
for(int a=10;a<=20;a++){
if(a==16){
break;
}
System.out.println(a);
}
}
}

Output :
10
11
12
13
14
15