break continue statements in Java

break statement in Java

The break statement in C, C++ and Java terminates the statement sequence. We saw it in the Switch case as well. In Java, we can use break as,

  • break in switch
  • break as goto
  • break outside label

Let us first see the syntax,

Syntax

Example

Let us see an example to learn more about break statement in Java,

Output

The following is the output,

break statement in Java

break in switch statement in Java

Let us see an example to learn about the usage of break in switch statement in Java,

The following is the output,

Java Break in Switch Statement

break as goto in Java

Let us see an example to learn about the usage of break as goto in Java,

The following is the output,

Break statement as Goto in Java

continue statement in Java

The continue statement transfers control to the conditional expression and jumps to the next iteration of the loop.

Syntax

Example

The following is an example showing the usage of continue statement,

The following is the output,

continue statement in Java

continue as goto in Java

Let us learn about how to work with continue statement as goto in Java,

The following is the output,

continue as goto in Java

In this lesson, we learned how to work with break and continue in Java.

Java Variables
StringBuffer class in Java
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading