Skip to content
Justice Tech School

Arrays

arrayOf and intArrayOf create fixed size arrays. Indexing starts at 0.

Example
val a = arrayOf("a", "b")
val n = intArrayOf(3, 1, 2)
n.sort()
println(n.joinToString())
println(a.size)
println(IntArray(3) { it * it }.toList())

Exercise

Sort in place.

n.()

Quiz Test

What does IntArray(3) { it } build?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.