To declare an integer array in Kotlin, you can use the IntArray
constructor or array initialization syntax.
In this example,
numbers
with predefined values.intArrayOf
function.fun main() {
val numbers = intArrayOf(1, 2, 3, 4, 5)
println("Integer Array: ${numbers.joinToString()}")
}
Integer Array: 1, 2, 3, 4, 5
In this example,
emptyArray
.fun main() {
val emptyArray = IntArray(0)
println("Empty Integer Array: ${emptyArray.joinToString()}")
}
Empty Integer Array:
In this tutorial, we learned How to Declare an Integer Array in Kotlin language with well detailed examples.