We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3b7ae83 commit 4d3cfe5Copy full SHA for 4d3cfe5
2017-10-13/BreakDem.class
518 Bytes
2017-10-13/BreakDem.java
@@ -0,0 +1,41 @@
1
+/*
2
+ 控制跳转语句:
3
+ 1,break; 中断
4
+ 2,continue; 继续
5
+ 3,return; 返回
6
+
7
+ break的使用场景:
8
+ 1,switch语句中 表示结束switch语句。
9
+ 2,在循环语句中
10
+ 注意事项:离开了使用场景就没有任何意义了。
11
12
+ break在循环中的作用:
13
+ 1,退出单层循环 结束单层循环
14
+ 2,退出多次循环
15
+*/
16
+class BreakDem
17
+{
18
+ public static void main(String[] args){
19
+ //错误: 在switch或loop外部中断
20
+ //break;
21
+ //退出单层循环
22
+ /*
23
+ for(int i = 1; i <= 10; i++){
24
+ //为了验证执行了多少次
25
+ System.out.println(i);
26
+ if( i == 3){
27
+ break;
28
+ }
29
+ }*/
30
+ wc:for(int x = 1; x <= 4; x++){
31
+ nc:for(int y = 1; y <= 5; y++){
32
+ if(y == 3){
33
+ break wc;
34
35
+ System.out.print("*");
36
37
38
39
40
41
+}
0 commit comments