This article explores different ways to convert a character array to a string in Kotlin.

1. Using String Constructor

The standard solution to convert characters of the specified array into a string is using the String constructor.

Download Code

 
Additionally, the String constructor can be invoked as:

Download Code

2. Using joinToString() function

The joinToString() function is used to create a string from the character Sequence separated by a delimiter. To create a plain string, pass an empty string to the joinToString() function.

Download Code

3. Using concatToString() function

Alternatively, you can use the concatToString() function, which concatenates characters in the CharArray into a string.

Download Code

4. Using StringBuilder

Here, the idea to iterate over the characters of the specified array and append each char to a StringBuilder instance. Finally, make a call to the toString() function to get a string call.

Download Code

That’s all about converting a character array to a string in Kotlin.