Convert String to Char Array in Kotlin

thumbnail

In this tutorial, you will learn to convert a string to char array using String method toCharArray() in Kotlin().

Example: Convert String to Char Array in Kotlin

import java.util.Arrays
fun main(args: Array<String>) {
    val st = "Hello world"
    val chars = st.toCharArray()
    println(Arrays.toString(chars))
}

The output will be:

[H, e, l, l, o,  , w, o, r, l, d]

Read More:

Back To Top