当前位置:网站首页>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 ,
边栏推荐
- Playwright tutorial (II) suitable for Xiaobai
- 2022最新软件测试八股文,能不能拿心仪Offer就看你背得怎样了
- The dragon lizard exhibition area plays a new trick this time. Let's see whose DNA moved?
- zigbee开发板(nxpzigbee开发)
- 别投了,软件测试岗位饱和了...
- C语言:随机生成数+选择排序
- 2 lines of code to generate a solid desktop background
- 信息安全建设原则指导
- El expression improves JSP
- Tesseract OCR初探
猜你喜欢

关于接口测试你想知道的都在这儿了

6-18漏洞利用-后门连接

Solutions to the failure of win key in ikbc keyboard

Whether the five distribution methods will produce internal fragments and external fragments

8000 word super detailed custom structure type

【饭谈】如何设计好一款测试平台?

What have I experienced to become a harder tester than development?

JMeter websocket接口测试

这次龙蜥展区玩的新花样,看看是谁的 DNA 动了?

Having met a tester with three years' experience in Tencent, I saw the real test ceiling
随机推荐
[51Nod1676 无向图同构]无向图哈希[通俗易懂]
jsp九大内置对象
After three years of software testing at Tencent, I was ruthlessly dismissed in July, trying to wake up my brother who was paddling
mouseEvent事件——mouse坐标描述——focus事件——input事件——节流(thorttle)——mouseWheel(滚轮事件)
Can I buy financial products with a revenue of more than 6% after opening an account
开源的RSS订阅器FreshRSS
JSP nine built-in objects
zigbee开发板(nxpzigbee开发)
关于接口测试你想知道的都在这儿了
Wet- a good choice for people with English difficulties - console translation
Mouseevent event -- mouse coordinate description -- Focus event -- input event -- throttle -- mousewheel (wheel event)
What have I experienced to become a harder tester than development?
EL表达式改进JSP
核电站在席卷欧洲的热浪中努力保持安全工作
kubernetes之VictoriaMetrics单节点
[hand torn STL] unordered_ set、unordered_ Map (encapsulated with hash table)
[fan Tan] in detail: lower control, upward management, upward drawing cake.
Animation curves are used every day. Can you make one by yourself? After reading this article, you will!
2022 love analysis ― bank digitalization practice report
如何将一个域名解析到多个IP地址?