当前位置:网站首页>Jump statement in day011 loop structure
Jump statement in day011 loop structure
2022-07-24 03:16:00 【Mo Nian】
break:
Action scenario :switch Select structure and cycle structure
effect :
stay switch Encountered in the selection structure break, End the whole switch Selection structure , perform switch Select the code behind the structure
Encountered in the loop structure break, Then all subsequent operations of the whole cycle structure are ended , Execute the code after the loop structure
Be careful :
break General combination if Select statements to use together
public class BreakDemo02 {
public static void main(String[] args) {
for (int i = 1; i <=20; i++) {
System.out.println(i);
// Judge i Value , See if it has arrived 10, If it comes to 10 了 , It should end the whole for loop
if(i==10){
break;// End the whole thing for loop
}
}
}
}
continue:
Action scenario :
It can only act in the circular structure
effect :
End the present ( This time ) Cycle subsequent operations , Continue with the next cycle
Be careful :
continue General combination if Statement together
public class ContinueDemo01 {
public static void main(String[] args) {
for (int i = 1; i <= 20; i++) {
if (i == 10) {
continue;// When i==10 when , End this cycle , Enter the iteration section
}
System.out.println(i);
}
}
}
public class BreakDemo01 {
public static void main(String[] args) {
// break Use in double loop , In the inner loop break The end is the inner loop , If you want to end the outer loop , You need to use tags to end which loop the table name
// a: b: Marking loops
a: for (int i = 1; i <= 5; i++) {
System.out.print(i + "---");
b: for (int j = 10; j <= 50; j += 10) {
if (j == 40) {
continue b;// Terminate the entire outer cycle
}
System.out.print(j + " ");
}
System.out.println();
}
}
}
边栏推荐
猜你喜欢

轮播图van-swipe的报错:cannot read a properties of null(reading width)

Simulink code generation: variable subsystem and its code

【HDLBits 刷题】Verilog Language(2)Vectors 部分

Ue5 split screen (small map) solution

322. Change

C文件操作详解

The implementation in unity determines whether missing or null

C user defined type details

The error of van swipe in the rotation chart: cannot read a properties of null (reading width)

在openEuler社区开源的Embedded SIG,来聊聊它的多 OS 混合部署框架
随机推荐
Simulink code generation: variable subsystem and its code
TCP data transmission and performance
How to realize software function safety
Binary search
二分查找
Ugui source code analysis - maskablegraphic
CMT registration - Google Scholar ID, semantic scholar ID, and DBLP ID
The new idea 2022.2 was officially released, and the new features are nice
openEuler 资源利用率提升之道 01:概论
Unity Message push
Unity message push
Summernote supports custom video upload function
OSPF comprehensive experimental configuration
C. Minimum Ties-Educational Codeforces Round 104 (Rated for Div. 2)
uva1445
Ways to improve the utilization of openeuler resources 01: Introduction
It's solved with a cry
PMP preparation experience | good habits, good process, good results
Services et configurations FTP
MySQL sub database and sub table and its smooth expansion scheme