当前位置:网站首页>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 ,
边栏推荐
- c sqlite ... ...
- 2022最新软件测试八股文,能不能拿心仪Offer就看你背得怎样了
- Detailed summary of C language game dual cache to solve the flash screen problem [easy to understand]
- Having met a tester with three years' experience in Tencent, I saw the real test ceiling
- Guiding principles of information security construction
- How to use RS485 half duplex chip correctly
- golang : MVC之models
- Wechat applet application development competition works comprehensive development record - Jinlu cultural tourism (cloud development - Overview)
- Animation curves are used every day. Can you make one by yourself? After reading this article, you will!
- 3day
猜你喜欢
![[go basics 02] the first procedure](/img/af/f32762a828f384bf6aa063ebf959aa.png)
[go basics 02] the first procedure

还不懂mock测试?一篇文章带你熟悉mock

『Skywalking』. Net core fast access distributed link tracking platform

Victoriametrics single node of kubernetes

2022 love analysis ― bank digitalization practice report

2022 the latest software tests eight part essay. Whether you can offer depends on how you recite it
![[dinner talk] those things that seem to be for the sake of the company but are actually incomprehensible (2: soft quality](/img/11/42c4674d23ee93850fb3d2de0d0932.png)
[dinner talk] those things that seem to be for the sake of the company but are actually incomprehensible (2: soft quality "eye edge" during interview)

动画曲线天天用,你能自己整一个吗?看完这篇你就会了!

Don't vote, software testing posts are saturated

『SignalR』. Net using signalr for real-time communication
随机推荐
YUV420 YUV420sp 图像格式「建议收藏」
3day
3. Editors (vim)
c sqlite ... ...
【GO基础02】第一个程序
Don't vote, software testing posts are saturated
Special class design
Dovecot set mailbox quota
2day
Animation curves are used every day. Can you make one by yourself? After reading this article, you will!
Application of breakthrough thinking in testing work
JSP初识
JSP novice
Acwing 866. determining prime numbers by trial division
Three ways to allocate disk space
Mouseevent event -- mouse coordinate description -- Focus event -- input event -- throttle -- mousewheel (wheel event)
Nuclear power plants strive to maintain safety in the heat wave sweeping Europe
磁盘空间的三种分配方式
少儿编程 电子学会图形化编程等级考试Scratch一级真题解析(判断题)2022年6月
Fill the whole square with the float property