Is there a simple way of converting a Java ArrayList to a Kotlin Array? The following code:
fun test(): Array<String> {
val elems = ArrayList<String>()
return elems.toArray()
}
gives the error:
main.kt:2:15: error: unresolved reference: ArrayList
val elems = ArrayList<String>()
^
I'm parsing some JSON and don't know how many elements I'm going to end up with, but once I've read them I don't need to modify the data in any way so I thought I'd go with Kotlin arrays as the data type.