Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
Tags
- 명세기반테스트
- continue to
- Realtime Rendering
- sort함수
- 명절 표현
- counldn't have
- know
- end up ing
- gameQA
- UE4
- it's a good thing
- by any chance
- ISTQB
- relif
- keep -ing
- might have p.p
- 형변환
- I'm glad
- C++
- for ing
- html
- 게임QA
- happen to
- 변수
- if조건절
- by until
- 제5인격
- java
- 코로나19
- metascore
Archives
- Today
- Total
Records rather than Memories
[java] break, continue 본문
break
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
package javatutorials.loop;
public class BreakDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
for (int i = 0; i < 10; i++) {
if(i == 5)
break;
System.out.println("Let's go! " + i);
}
}
}
|
cs |
break는 반복문에서 빠져나가기 위해 사용한다.
다음과 같이 if 문에서 참이면 break를 만나 for문을 빠져나간다.
따라서 출력은 Let's go 4까지만 이루어진다.
continue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
package javatutorials.loop;
public class ContinueDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
for (int i = 0; i < 10; i++) {
if(i == 5)
continue;
System.out.println("Let's go! " + i);
}
}
}
|
cs |
continue는 만나는 즉시 for문 반복문으로 돌아간다.
'Software > JAVA' 카테고리의 다른 글
배열 (0) | 2019.10.16 |
---|---|
반복문의 중첩 (0) | 2019.10.15 |
[java] for문 (0) | 2019.10.15 |
[java] while 반복문 (0) | 2019.10.15 |
논리 연산자 (0) | 2019.10.15 |
Comments