java tutorial - Java break statement - tutorial java - java programming - learn java- java basics - java for beginners

Learn Java - Java tutorial - Java operator break - Java examples - Java programs
In the Java programming language, Java break statement has the following two uses:
- When a break statement occurs within a loop, the loop is terminated, and program control resumes from the next statement.
- It can be used to terminate the case in a switch statement (see the next lesson for more details).

Learn java - java tutorial - java-break-statement - java examples - java programs
Syntax
The syntax of a single break statement in Java within any loop:
break;
click below button to copy the code. By - java tutorial - team
Process description

Learn java - java tutorial - break-statement - java examples - java programs
Sample Code
public class Test {
public static void main(String args[]) {
int [] numbers = {10, 20, 30, 40, 50};
for(int y : numbers ) {
if( y == 30 ) {
break;
}
System.out.print( y );
System.out.print("\n");
}
}
}
click below button to copy the code. By - java tutorial - team
Output
10
20