언어/JAVA
java) 레이블 outer 를 사용하여 반복문 탈출하기
[Nada]
2019. 11. 29. 15:11
- outer 를 사용하여 특정 조건 만족할 시 반복문 탈출
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
public class ContinueBreak {
public static void main(String[] args) {
outer: for(int i=1; i<10; i++) {
for(int j=1; j<10; j++) {
if(i*j == 72) {
System.out.println(i + " x " + j + " = " + i*j);
break outer;
}
}
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |