반응형
Notice
Recent Posts
Recent Comments
Link
목록foreach (1)
불로구
[코틀린 기초] 12. 반복문 (for, forEach)
코틀린을 활용한 여러가지 반복문을 알아보자 package com.example.myapplication.Kotlin fun main(array: Array){ var a = mutableListOf(1,2,3,4,5,6,7,8,9) //반복 1 for(item in a){ if(item == 5){ println("다섯번째") }else { println(item) } } //반복 2 for((index, item) in a.withIndex()){ println("index : $index , value : $item") } // 반복 3 a.forEach{ println(it) } println() //반복 4 a.forEach{ item -> println(item) } //반복 5 a.forEac..
프로그래밍/코틀린
2021. 3. 1. 15:08