-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBreakCyc.java
More file actions
28 lines (26 loc) · 863 Bytes
/
BreakCyc.java
File metadata and controls
28 lines (26 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package java02;
public class BreakCyc {
public static void main(String[] args){
System.out.println("\n-----------中断单层循环例子----------");
String[] array = new String[]{"蛤蟆1","蛤蟆2","蛤蟆3","蛤蟆4","蛤蟆5","蛤蟆6","蛤蟆7","蛤蟆8","蛤蟆9","蛤蟆10","蛤蟆11"};
System.out.println("在你发现蛤蟆7之前,告诉我有啥");
for(String string : array){
if(string.equals("蛤蟆7")){
break;
}
System.out.println("有"+string);
}
System.out.println("\n-----------中断双层循环例子----------");
int [][] myScores = new int[][]{{61,62,63,64,65},{51,52,53,54,55},{71,72,73,74,75}};
System.out.println("考试成绩:\n 数学\t 语文\t 英语\t 政治\t 历史");
No1:for(int[] is :myScores){
for(int i:is){
System.out.println(i+"\t");
if(i<60){
System.out.println("\n 等等,"+i+"的分是什么,咋不及格");
break No1;
}
}
}
}
}