Jump Statements in Java

Last Updated : 26 Nov, 2026

Jump statements in Java transfer control from one part of a program to another, interrupting the normal execution flow. They are commonly used in loops, switch statements and methods.

  • Support early termination of loops and methods.
  • Allow conditional skipping of statements during execution.

Types of Jump Statements

Java provides three commonly used jump statements:

1. Continue Statement

The continue statement pushes the next repetition of the loop to take place, skipping any code between itself and the conditional expression that controls the loop.

Java
import java.io.*;
class GFG{
    public static void main(String[] args){
        for (int i = 0; i < 5; i++){
            if (i == 2){
                  System.out.println();
                  
                  // using continue keyword 
                  // to skip the current iteration
                continue;
            }
            System.out.println(i);
        }
    }
}

Output
0
1

3
4

Explanation: In the program, when the value of i is 2, the compiler encounters the continue statement, and then 2 is skipped.

Flowchart of continue Statement

Flowchart-of-continue-Statement

2. Break Statement

The break statement terminates the nearest enclosing loop or switch statement. Control transfers to the statement immediately following it.

Example: Using break to terminate a loop.

Java
import java.io.*;
class GFG{
    public static void main(String[] args)
    {
        int n = 10;
        for (int i = 0; i < n; i++) {
            if (i == 4)
                break;
            System.out.println(i);
        }
    }
}

Output
0
1
2
3

Explanation: The loop is designed to iterate from 0 to 9. However, when i becomes 4, the break statement terminates the loop immediately. Therefore, only 0, 1, 2, and 3 are printed.

Flowchart of break Statement

Break-Statement-Flow-Diagram

Labeled Break Statement

A labeled break terminates an enclosing labeled statement or block. It is useful for exiting nested loops directly.

Java
class Geeks{
    public static void main(String[] args){
        outer:
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (j == 2)
                    break outer;

                System.out.println(i + " " + j);
            }
        }
    }
}

Output
0 0
0 1

Explanation: When j becomes 2, break outer terminates both the inner and outer loops.

3. Return Statement

The "return" keyword can help you transfer control from one method to the method that called it. Since the control jumps from one part of the program to another, the return is also a jump statement.

  • "return" is a reserved keyword means we can’t use it as an identifier.
  • It is used to exit from a method, with or without a value.
Java
class Geeks{
    static int add(int a, int b){
        return a + b;
    }

    public static void main(String[] args){
        System.out.println(add(5, 10));
    }
}

Output
15

Explanation: The add() method calculates the sum and returns it to the calling method.

Comment