kotlin convert array to arrayList
To convert an array to an ArrayList in Kotlin, follow these steps:
- Create an array.
- Use the toList() function to convert the array to a list.
- Use the ArrayList constructor to create an ArrayList from the list.
Here's an example:
val array = arrayOf(1, 2, 3, 4, 5)
val list = array.toList()
val arrayList = ArrayList(list)