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.