当前位置:网站首页>What are the differences and usages of break and continue?
What are the differences and usages of break and continue?
2022-06-11 06:24:00 【***Nobody】
break and continue Mostly used in circular statements ,return Mostly used in functions .
1.break
break Usage of : End the cycle .
analysis : When in a for Use in loop break sentence , Will exit the entire loop , In the code snippet , When i=5 when , Exit the whole cycle , therefore , Output numbers only to 4.
The results are shown in the following figure
public class Test {
public static void main(String[] args) {
int N=10;
for (int i = 0; i < N; i++) {
if(i==5){
break;
}
System.out.printf("i The value of is %d\n",i);
}
}
}
The results are shown in the following figure 
2.continue
continue Usage of : Jump out of this loop statement , Go straight to the next .
analysis : When used in a loop statement continue when , In this cycle continue The following statement is no longer executed , Jump directly to the next loop statement .
public static void main(String[] args) {
int N=10;
for (int i = 0; i < N; i++) {
if(i==5){
continue;
}
System.out.printf("i The value of is %d\n",i);
}
}
The results are shown in the following figure , Skip the 5, Carry out the following 678…
边栏推荐
- Simple understanding of XML and JSON
- Cenos7 builds redis-3.2.9 and integrates jedis
- Global case | how Capgemini connects global product teams through JIRA software and confluence
- Vulhub 8.1-backdoor vulnerability recurrence
- CCS安装编译器的方法
- []==![]
- instanceof到底是怎样判断引用数据类型的!
- Handwritten promise [01] - Implementation of promise class core logic
- Sqli-libs post injection question 11-17 actual combat
- Chapter 6 of machine learning [series] random forest model
猜你喜欢

FPGA Design -- ping pong operation implementation and Modelsim simulation

Vulhub 8.1-backdoor vulnerability recurrence

What is sentinel produced by Ali?

Fix the problem that the right mouse button does not have a vscode shortcut

break,continue有什么区别和用法?

Verilog realizes binocular camera image data acquisition and Modelsim simulation, and finally matlab performs image display

箭头函数的this指向

Learn a trick to use MySQL functions to realize data desensitization

ERROR 1215 (HY000): Cannot add foreign key constraint

jenkins-不同风格的项目构建
随机推荐
Simple understanding of XML and JSON
Multimedia框架解析之MediaExtractor源码分析(一)
235-二叉搜索树的最近公共祖先
PHP laravel8 send email
FPGA interview notes (IV) -- sequence detector, gray code in cross clock domain, ping-pong operation, static and dynamic loss reduction, fixed-point lossless error, recovery time and removal time
Basic use of BufferedReader and bufferedwriter
Servlet
Markdown + typora + picgo experimental report template attached
Alias the path with the help of craco
解决ffmpeg獲取AAC音頻文件duration不准
Handwritten promise [01] - Implementation of promise class core logic
动态import
Quantitative understanding (Quantitative deep revolutionary networks for effective information: a whitepaper)
Using idea to add, delete, modify and query database
This point of arrow function
Box model
Vulnhub's breach1.0 range exercise
Docker安装Mysql、Redis
jenkins-用户权限管理
使用Meshlab对CAD模型采样点云,并在PCL中显示