In Java, jump statements control the flow of execution in a program by allowing some to skip sections of source code or terminate loops and methods. The primary jump statements in Java are break, continue, and return. Each statement serves a unique purpose and can significantly affect your code’s execution. This article will explore the jump statement in detail, providing examples to illustrate its usage.
What is a jump statement in Java?
A jump statement in Java is a control statement that allows execution flow to jump to a specific point in the program, interrupting the normal sequential execution. The main jump statements in Java, break, continue, and return, are used to exit loops, skip iterations, or return from methods.

POSTGRADUATE PROGRAM IN
Multi Cloud Architecture & DevOps
Master cloud architecture, DevOps practices, and automation to build scalable, resilient systems.
Types of jump Statements in Java
There are four types of Jump statements in Java language.
- Break Statement
- Continue Statement
- Return Statement
Break Statement in Java
The break statement exits a loop or switch statement before its natural termination. When break is encountered, the control jumps out of the loop or switch block and moves to the statement immediately following.
Syntax
break ;
Using break with a for Loop
class Main{
public static void main(String args[]){
for(int i = 1 ;i<=5 ;i++){
System.out.println("Location iteration = "+i);
if(i > 3){
break;
}
}
}
}
Output
Location iteration = 1
Location iteration = 2
Location iteration = 3
Location iteration = 4
Explanation
- The following example, we have a for loop that starts with int i =1 and continues as long as i is less than or equal to 5 (i<=5 ).
- The loop will iterate from i = 1 to i=5, and during each iteration. It prints the current value of i using System.out.println(“Loop Iteration” +i).
- We have an if statement inside the loop that checks if i> 3. If the condition is true, the break statement is executed.
- The loop is exited prematurely, and the program continues with the source code with the code after the loop.
Using break with a while loop
class Main{
public static void main(String args[]){
int i = 1 ;
while(i<= 5){
System.out.println("Loop Iteration "+i);
i++ ;
if(i> 3){
break;
}
}
}
}
Output
Loop Iteration 1
Loop Iteration 2
Loop Iteration 3
Explanation
- In this example, we have a for loop that starts with int i =1 and continues as long as less than or equal to 5 (i <=5).
- The loop will iterate from i = 1 to i =5 and during each iteration, it prints the current value of i using the System.out.println(“Loop Iteration” +i).
- We have an if statement inside the loop that checks if i > 3. If the condition is true, the break statement is executed.
- The result is that the loop is exited prematurely, and the program will continue the source code in the loop.
continue Statement
The continue statement in Java is a control flow statement used within loops. It allows you to skip the current iteration of a loop and proceed to the next iteration. The continue statement can be used in for, while and do-white loops.
Syntax
continue ;
continue with a for loop.
Program
public class Main{
public static void main(String args[]){
for(int i = 0;i<=5 ;i++){
if(i== 3){
continue ;
}
System.out.println("Loop Iteration ="+i);
}
}
}
Output
Loop Iteration =0
Loop Iteration =1
Loop Iteration =2
Loop Iteration =4
Loop Iteration =5
Return Statement in Java
Using return statement in Java: A return statement is used in Java to mark the end of a method and go back to its caller’s place. It can also provide a value to the method when the method has a particular return type. That makes the return statement compulsory for methods in Java if you want to return some value or a result from a method.
Using return without a value:
The following program demonstrates the return statement without a value. It is used to exit the method without returning any value.
Program
public class Main{
public static void Hellow(){
System.out.println("Harry Potter");
}
public static void main(String[] args) {
Hellow() ;
}
}
Output
Harry Potter
Using return with a value
In this section, the return type other than void, such as int, doubly, String, or any other data type, the return statement is used to exit the method and return a value of the specified type.
Program
public class Main{
public static int addition(int x, int y){
return x + y ;
}
public static void main(String[] args) {
int output = addition(20,30) ;
System.out.println(output);
}
}
Output
50

82.9%
of professionals don't believe their degree can help them get ahead at work.
Advantages and Disadvantages of Jump Statements in Java
Let’s discuss the advantages and disadvantages of Jump Statement in Java language:
| Jump Statement | Advantages | Disadvantages |
| break | It allows immediate exit from loops or switch blocks, improving control flow and simplifying code by preventing unnecessary iterations. | If overused or misused, it can make the program harder to read and disrupt the logical flow of nested loops, reducing clarity. |
| continue | It skips the current iterations and moves to the next iterations, making it useful for specific conditions inside the loops and enhancing flexibility. | It makes code less effective if the reader does not clearly understand it. Overuse may lead to less structured loop management. |
| return | It efficiently exits methods, transferring control back to the caller. Reducing complex conditions in methods can improve source code readability. | Excessive use may lead to premature exits, making debugging and source code flow harder to follow. Using multiple return points in a method can also reduce maintainability. |
Also Read: Java Interview Questions and Answers
Conclusion
The jump statements in Java: they are the break, statement, continue and return. They are essential in managing the control flow, especially in instances such as loops, switches and methods. The break statements are used to terminate a loop or a switch block altogether and thus, no further execution will take place in the current environment. The other is the continue statement, which provides more control to the loop by letting it go directly to the next iteration without completing the current one. The return statement used within methods allows the method to be excited and, if required, to pass back a specific value to the method that is called. These statements give Java programs improved modulation and readability and afford fine-grained control over how a program is to run. Enrol in Hero Vired’s Certificate Program in Application Development to explore Java in detail.
What is the purpose of the break statement in Java?
Can break be used outside of loops or switch statements?
How does the return statement differ from the break and continue?
Can you use return in a loop?
What happens if you use a break as a method?
Updated on February 18, 2025
