공부
[kotlin] arrayOf("a", "b", "c").toList()
승가비
2022. 12. 20. 22:22
728x90
fun main(args: Array<String>){
val array: Array<String> = arrayOf("a", "b", "c", "d", "e")
val list: List<String> = array.toList()
list.forEach {
println(it)
}
}
https://codechacha.com/ko/kotlin-convert-list-to-array/
Kotlin - Array를 List로 변환
코틀린에서 배열을 리스트로 변환하는 방법을 소개합니다. `toList()`는 List를 Array로 변환합니다. `toMutableList()`는 List가 아닌 MutableList로 리턴합니다. 다음과 같이 `listOf()`로 변환할 수 있습니다.
codechacha.com
728x90