Convert Char Array to String in Kotlin

thumbnail

In this tutorial you will learn to convert a char array to a string in Kotlin.

Example: Convert Char Array to String in Kotlin

fun main(args: Array<String>) {
    val ch = charArrayOf('a', 'i', 'u', 'e', ‘o’)
    val st = String(ch)
    val st2 = String(ch)
    println(st)
    println(st2)
}

The output will be:

aeiou
aeiou

We have created a char array ch containing vowels. Then, We use String’s valueOf() method to convert the character array to String. You can also use the String constructor which takes character array ch as parameter for conversion.

Back To Top