Menu

Jump Statements in Java
📰

Jump Statements in Java

DEV Community: java·ABISHEK M·3 days ago
#wFQc6Mt0
#devtojava#devto#dev#return#method
Long article (1697 words) — no AI summary yet.
Reading 0:00
15s threshold

1. What are Jump Statements?

Jump statements are used to change the normal flow of program execution.

Normally, Java executes statements one by one. But sometimes, we need to:

Stop a loop immediately.

Skip the current iteration of a loop.

Exit from a method.

Return a value from a method.

Java provides three main jump statements:

break

continue

return

2. Break Statement

The break statement is used to terminate a loop or a switch statement immediately.

When Java encounters break , it exits the nearest enclosing loop or switch.

Syntax

break ;

Enter fullscreen mode

Exit fullscreen mode

Example: Break in a for loop

public class Main { public static void main ( String [ ] args ) {

for ( int i = 1 ; i <= 5 ; i ++ ) {

if ( i == 3 ) { break ; }

System . out .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.