This article explores different ways to convert an IntArray to a list of Integer using Kotlin.

1. Using toList() function

The standard way to convert an array to a list is with toList() or toMutableList() function. The toList() function creates an immutable list, while toMutableList() function creates a mutable list.

Download Code

2. Using toCollection() function

You can also specify the List implementation of your choice using the toCollection() function. This is demonstrated below:

Download Code

3. Using listOf() function

You can also use the listOf() or mutableListOf() function. But first, you need to convert the primitive array to the typed array and prefix it with * (Spread operator).

Download Code

4. Custom Routine

Finally, you can write your own logic for this task. The idea is to use a foreach loop to add elements from the IntArray array to a mutable list.

Download Code

That’s all about converting IntArray to Integer list in Kotlin.