1. What are Jump Statements?
Jump statements are used to change the normal flow of program execution.
Normally, Java executes statements one by one. But sometimes, we need to:
Stop a loop immediately.
Skip the current iteration of a loop.
Exit from a method.
Return a value from a method.
Java provides three main jump statements:
break
continue
return
2. Break Statement
The break statement is used to terminate a loop or a switch statement immediately.
When Java encounters break , it exits the nearest enclosing loop or switch.
Syntax
break ;
Enter fullscreen mode
Exit fullscreen mode
Example: Break in a for loop
public class Main { public static void main ( String [ ] args ) {
for ( int i = 1 ; i <= 5 ; i ++ ) {
if ( i == 3 ) { break ; }
System . out .…