This article explores different ways to convert a string to a list of characters in Kotlin.

1. Using toList() function

The standard solution to convert a string to a list of characters in Kotlin is with the toList() function.

Download Code

 
To get a mutable list, you can use the toMutableList() function:

Download Code

2. Using foreach Loop

Another solution is to create a new List and add elements to it using a foreach loop.

Download Code

 
You can also use the forEach() function, as shown below:

Download Code

 
Finally, you can use the IntRange with forEach() to directly access each character and add it to the list.

Download Code

That’s all about converting a string to a list of characters in Kotlin.