当前位置:网站首页>On the difference between break and continue statements
On the difference between break and continue statements
2022-07-25 22:08:00 【Bao Zhou Pao】
Concept :
Break Is to jump out of the cycle , That is to say, to Break When the sentence is , Within this cycle Break The content after the statement is no longer executed , And the whole cycle ends .Continue It means to jump out of this cycle , Continue to the next cycle . Don't talk much , Direct example :
Example :
1、Continue Statement example :
//Continue Statement example :
public static void main(String[] args){
for(int i=1;i<=10;i++){
if(i==9){
System.out.println(" At present i The value of is :"+i);
continue;
}
System.out.println(" Carry on "+i);
}
System.out.println(" The loop ends ");
}
}
Running results :

You can see continue Statement to execute a loop first , When i The value of is 9 when , Output current i Value , Not in the execution of this continue Subsequent statements , Then start the next cycle , Until the cycle execution condition is not satisfied .
2、Break Statement example :
//break Statement example :
public static void main(String[] args){
for(int i=1;i<=10;i++){
if(i==9){
System.out.println(" At present i The value of is :"+i);
break;
}
System.out.println(" Carry on "+i);
}
System.out.println(" The loop ends ");
}
}Running results :

i Value Less than 9 when , Execution process and continue identical , When i The value is equal to the 9 when , Output current i Value , perform break sentence , End of cycle , It can be seen from the above operation results , Even if the loop execution condition is not reached, the loop will not continue to execute ,
边栏推荐
- 数据库进阶·如何针对所有用户数据中没有的数据去加入随机的数据-蜻蜓Q系统用户没有头像如何加入头像数据-优雅草科技kir
- How to implement an app application to limit users' time use?
- The file cannot be saved (what if the folder is damaged and cannot be read)
- EL表达式改进JSP
- Jmeter---设置代理录制请求
- 面了个腾讯三年经验的测试员,让我见识到了真正的测试天花板
- 什么是分区分桶?
- MySQL --- 子查询 - 列子查询(多行子查询)
- 成为比开发硬气的测试人,我都经历了什么?
- 【饭谈】Web3.0到来后,测试人员该何去何从?(十条预言和建议)
猜你喜欢
随机推荐
QML module not found
How to quickly build a picture server [easy to understand]
Flex layout
[assembly language 01] basic knowledge
Summary of function test points of wechat sending circle of friends on mobile terminal
C语言左值和右值说明[通俗易懂]
Basic knowledge in the project
Redis foundation 2 (notes)
Bitcoin.com:usdd represents a truly decentralized stable currency
Guiding principles of information security construction
C language: random generated number + bubble sort
TFrecord写入与读取
Collation of SQL statement exercises
The second short contact of gamecloud 1608
What should I do if I encounter the problem of verification code during automatic testing?
磁盘空间的三种分配方式
『SignalR』.NET使用 SignalR 进行实时通信初体验
YUV420 yuv420sp image format "recommended collection"
启牛商学院和微淼商学院哪个靠谱?老师推荐的开户安全吗?
After three years of software testing at Tencent, I was ruthlessly dismissed in July, trying to wake up my brother who was paddling




![[hand tear STL] BitSet (bitmap), bloom filter](/img/bc/a6e3c2ccce478460a2742852eee9cf.png)




