냠냠냠
java) 레이블 outer 를 사용하여 반복문 탈출하기 본문
- 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 |
'언어 > JAVA' 카테고리의 다른 글
java) 100 이하 소수(Prime Number) 출력하기 (0) | 2019.12.02 |
---|---|
java) 두 자리수 덧셈 합 99 만족하는 수 조합 찾기 (0) | 2019.11.29 |
java) 구구단 짝수 단 조건부 출력하기 (0) | 2019.11.29 |
java) 자연수 1부터 시작해서 홀수를 더했을 때... (0) | 2019.11.28 |
java) 5의 배수이면서 7의 배수인 정수를 출력하기 (0) | 2019.11.28 |
Comments