728x90

Kotlin의 반복문
For 반복문
for (item in collection) println(item)
for (i in 1..3 step 2) print(i.toString() + " ")
출력 : 1 3
for (i in 3 downTo 0) print(i.toString() + " ")
출력 : 3 2 1
While 반복문
while (조건) {
내용
}
do {
내용
} while (조건)
break / continue
반복문에서 break와 continue를 사용할 수 있다.
반응형
'언어 > Kotlin' 카테고리의 다른 글
| [Kotlin] 공개 상태 (0) | 2023.03.10 |
|---|---|
| [Kotlin] 클래스 관계 (0) | 2023.03.03 |
| [Kotlin] 클래스 생성 , 생성자 (0) | 2023.02.28 |
| [kotlin] null 처리 (0) | 2023.02.24 |
| [Kotlin] 구조 , 조건문 (0) | 2023.02.17 |