Friday 1 December 2017

Kotlin: Define array of nulls

Kotlin provides 'arrayOfNulls' library function to define array of null values.

ArrayOfNulls.kt
fun main(args: Array<String>) {

 var a: Array<Int?> = arrayOfNulls(5)

 for (element in a) {
  println(element)
 }

}

Output
null
null
null
null
null


Previous                                                 Next                                                 Home

No comments:

Post a Comment