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;
For example:
##(Video tutorial recommendation:java video)
Output result:10 20Then 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;Example: Output result:
10 20 40 50Recommended tutorial:
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!