Home > Java > Javagetting Started > body text

What are the functions of break and continue keywords in java

王林
Release: 2020-05-31 15:56:33
Original
3717 people have browsed it

What are the functions of break and continue keywords in java

Let’s first look at the break keyword. The break keyword is mainly used in loop statements or switch statements to jump out of the entire statement block.

It can also jump out of the innermost loop and continue to execute the statements below the loop.

Grammar format

break;
Copy after login

For example:

What are the functions of break and continue keywords in java

##(Video tutorial recommendation:

java video)

Output result:

10
20
Copy after login

Then let’s take a look at the continue keyword. The continue keyword is suitable for any loop control structure. Its function is to make the program jump to the next time immediately. Iteration of the loop.

In a for loop, the continue statement allows the program to immediately jump to the update statement; in a while or do...while loop, the program immediately jumps to the judgment statement of the Boolean expression.

Grammar format:

continue;
Copy after login

Example:

What are the functions of break and continue keywords in java

Output result:

10
20
40
50
Copy after login
Recommended tutorial:

java Getting started

The above is the detailed content of What are the functions of break and continue keywords in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template