Kotlin Arrays

Arrays

Array is a collection of items belonging to same data type. arrayOf() function can be used to create an array.

arrayOf("apple", "banana", "cherry")
arrayOf(10, 20, 30, 40, 50)

An array is stored under a single variable name.

val names = arrayOf("apple", "banana", "cherry")
val numbers = arrayOf(10, 20, 30, 40, 50)

The elements in an array are ordered, meaning, individual elements can be accessed using index.

val names = arrayOf("apple", "banana", "cherry")
println(names[1])

There are much more to learn about Arrays, and the following section will help you with that.

Arrays Tutorials

We have consolidated all the tutorials related to arrays in the following tutorial. Please do follow.