Arrays are represented by a Class Array in Kotlin. The following code snippet shows some of the important properties and methods in the Array class:
class Array<T> private constructor() { val size: Int operator fun get(index: Int): T operator fun set(index: Int, value: T): Unit operator fun iterator(): Iterator<T> // ... }
An array can be created using the intArrayOf fu
val intArray = intArrayOf(1, 2, 10)
The following code snippet shows some of the important operations that can be performed on an array:
println(intArray[0])//1 println(intArray.get(0))//1 println(intArray.all { it > 5 }) //false println(intArray.any { it > 5 }) //true println(intArray.asList())//[1, 2, 10] println(intArray.max())//10 println(intArray.min())//1