VOOZH about

URL: https://www.geeksforgeeks.org/java/jump-statements-in-java/

⇱ Jump Statements in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Jump Statements in Java

Last Updated : 23 Apr, 2026

In Java, jump statements control the flow of program execution by transferring control to another part of the code. They are mainly used in loops and decision-making structures to handle specific conditions efficiently. These statements help improve readability and control in programs.

  • Used to change the normal execution flow of a program
  • Help in exiting loops, skipping iterations, or returning from methods
  • Common jump statements: break, continue, and return

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.


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

Break statement

1. Using Break Statement to exit a loop:

In Java, the break statement is used to terminate the execution of the nearest looping statement or switch statement. The break statement is widely used with the switch statement, for loop, while loop, and do-while loop. 

When a break statement is executed inside a loop, the loop is terminated, and the control reaches the statement that follows the loop. Here is an example:


Output
0
1
2
3

Explanation: As you see, the code is meant to print 0 to 10 numbers using for loop, but it prints only 0 to 3 . as soon as i is equal to 4, the loop terminates. 

Flowchart of break Statement

πŸ‘ Break-Statement-Flow-Diagram

2. Use Break as a form of goto

Java does not have a goto statement because it produces an unstructured way to alter the flow of program execution. Java illustrates an extended form of the break statement. This form of break works with the label. The label is the name of a label that identifies a statement or a block of code.

When this form of break executes, control jumps out of the labeled statement or block.


Output
i=0
after label one
i=1
after label two
after label one
i=2
after label three
after label two
after label one

Explanation: In the above program, when i=0, the first if statement succeeds, and cause a break to label one and then prints the statement. When i=1, the second if statement succeeds, and cause a break to label two and then prints the statements. When i=2, the third if statement succeeds, and cause a break to the to label three and then prints all the three statements.

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.

Output
Calculating the sum of 5 and 10
The sum is: 15
Result: 15

Explanation: When we are calling a class calculateSum method that has return sum which returns the value of sum and that value gets displayed on the console.

Comment