Answers for "how to read string array in kotlin"

3

how to declare string array in kotlin

//String[] in Java equivalent Array<String> in Kotlin 
//eg.
var array1 : Array<String?> = emptyArray()
var array2: Array<String?> = arrayOfNulls(4)
var array3: Array<String> = arrayOf("Mashroom", "Kitkat", "Oreo", "Lolipop")
Posted by: Guest on January-04-2021
3

kotlin string to array

val str = "abcd"
val array: Array<String> = str.toCharArray().map { it.toString() }.toTypedArray()
Posted by: Guest on May-20-2021

Browse Popular Code Answers by Language