

Println( "print converted int array as string : "+ Arrays.toString(array)) converting list to array list.toArray(array) creating an empty intger array with size of list. Convert List to Array in Kotlin [package Hence, to see the actual contents inside the array, you should call Arrays.toString() method.ģ. If you print directly returned array then it prints memory address of the array. Next, call list.toArray(array) which internally copies all values from list to array. Kotlin base package has a function arrayOfNulls(int size) which takes the size of the array that should be created and it should hold the String type values.Īfter the array is created then it will have null values in it.

Therefore, always array size should be as same as List when doing a conversion.
