This article explores different ways to convert a String Array to an Int Array in Kotlin.

1. Using map() function

The standard solution is to use the map { … } with toInt() or toIntOrNull() function to convert each string in the string array to an integer. This results in a list, which can be converted to an integer array with toTypedArray() or toIntArray() function.

Download Code

 
If you need an extension function, do like:

Download Code

2. Using forEach() function

Another approach is to use the forEach. The idea is to create an integer array and assign values to it after converting the string values to an integer.

Download Code

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