The arrayOfNulls function

Arrays can also be initialized with null. To do this, call the arrayOfNulls function and mention the type to be stored in it:

fun nulls() {
val nullArray = arrayOfNulls<String>(5)
nullArray.set(0,"hello")
nullArray.set(3,"kotlin")

for (i in nullArray){
println(i)
}
}

This code assigns string values to the 0 and 3 indexes and prints the null array on the screen.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.199.181