Java – Jump Statement

In Java, Jump statements are used to interrupt loop or switch-case instantly to transfer the program control from one point to elsewhere in the program.
Java supports three jump statements:

  • continue.¬†
  • break¬†
  • return.

break: 

This statement is used within the loop or switch cases to terminate that statement or the current loop is immediately stopped and resumes at the next statement followed by a terminated loop. we can also say that it helps to break out from the middle of the loop.

Syntax of break statement:


continue: 

It is used in loops to jump immediately to the next iteration of the loop. continue is used with while loop or do/while loop and with for loop. When continue is used inside for loop then the control immediately jumps to the increment or decrement part of the for loop. And when used inside while loop or do/while loop then the control immediately jumps to the condition part.

Syntax of continue statement:


label break statement

Java does not support goto as it leads to unstructured programming. so instead of ‘goto‘ we can use label break statement which works like a goto statement.

Syntax of label:

Example of label break statement in Java:

Output:


Break statement.
Continue statement.