Java ArrayList to Kotlin Array -


is there simple way of converting java arraylist kotlin array? following code:

fun test(): array<string> {   val elems = arraylist<string>()   return elems.toarray() } 

gives error:

main.kt:2:15: error: unresolved reference: arraylist   val elems = arraylist<string>()               ^ 

i'm parsing json , don't know how many elements i'm going end with, once i've read them don't need modify data in way thought i'd go kotlin arrays data type.

why use array? kotlin arrays mutable java arrays. should use kotlin list, opposed mutablelist, immutable. why code doesn't compile: toarray returns object[], if want string[] list need use toarray version takes array it's argument.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -