October 2018
Intermediate to advanced
370 pages
9h 15m
English
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.
Read now
Unlock full access