Java Jump Statements: break, continue, return
Introduction
What are Jump statements in Java?
Types of Jump Statements in Java

Break statement in Java
- A break statement in Java assists to terminate the execution of a loop in a particular program.
- This statement transfers the control of the program to the next statement which is immediately after the current loop or switch.
- A break statement is used in an existing statement of a loop, especially an infinite loop, in order to exit from it.
- There are 3 types of Break Statements, those are "Exiting a Loop", "As a form of Goto", and "In a switch case".
Example
class break_statement
{
public static void main(String[] args)
{
int i=1;
for (;;i++) //infinite loop
{
if (i==5)
{
break;
}
else
{
System.out.println(i);
}
}
}
}
Output
1
2
3
4
Example
class break_statement_goto
{
public static void main(String[] args)
{
label_1:
{
label_2:
{
label_3:
{
for(int i=0; i<100; i++)
{
System.out.println("Inside Label_3");
if (i==3)
break label_3;
}
}
System.out.println("Inside Label_2");
}
System.out.println("Inside Label_1");
}
}
}
Output
Inside Label_3
Example
class Switch_Case
{
public static void main(String[] args)
{
char a = 'C';
switch (a)
{
case 'A':
System.out.println("Letter A");
break; //break statement to come out of switch
case 'C':
System.out.println("Letter C");
break;
default:
System.out.println("Default case: NO Letter Matched!");
}
}
}
Output
Letter C
Continue statement in Java
- The continue statement in Java never terminates the execution of any loops.
- It can only work inside the "loop statement".
- The primary job of the "Continue statement" is the iteration of that specific loop.
- Continue statement assists the bypass of all the other statements by making them fall under it.
- The nature of the Continue statement is to skip the current iteration and force for the next one.
Example
class continue_statement
{
public static void main(String[] args)
{
for(int i=0; i<=10;i++)
{
if (i<3)
{
Continue; //continues and goes to next iteration
}
System.out.println(i);
}
}
}
Output
3
4
5
7
8
9
10
Return statement in Java
- The return statement in Java is a type of jump statement which is primarily used only inside the functions or methods.
- If in a method, any code is written after using the Return statement that can be treated as an unreachable statement by the compiler.
- The purpose of using a Return statement is to terminate the current method of execution and transfer the control to the next "calling method".
- There are two types of Return statements, which are "Return with a value" and "Return without a value".
Example
class continue_statement
{
public static void main(String[] args)
{
int age = 12;
System.out.println("Using Return");
if (age<18)
return; //terminates the method
System.out.println("Will not get executed!");
}
}
Output
Using Return
Summary
In conclusion, it's important to understand Java jump statements, as they are essential tools in a programmer's toolkit. With the break, continue, and return statements at your disposal, you can ensure that your code is efficient, optimized, and easily readable. As each of these statements has its unique applications, it's important to understand where and when to make use of them, which is a valuable skill to acquire during Java Certification. With proper knowledge of these three basic commands, you'll be able to take your programming skills to the next level. So make sure you keep these statements top of mind when crafting our programs and web pages! Code like a pro with java jump statements.
Take our free skill tests to evaluate your skill!

In less than 5 minutes, with our skill test, you can identify your knowledge gaps and strengths.