Kotlin Arrays Arrays of Primitives


Example

These types do not inherit from Array<T> to avoid boxing, however, they have the same attributes and methods.

Kotlin typeFactory functionJVM type
BooleanArraybooleanArrayOf(true, false)boolean[]
ByteArraybyteArrayOf(1, 2, 3)byte[]
CharArraycharArrayOf('a', 'b', 'c')char[]
DoubleArraydoubleArrayOf(1.2, 5.0)double[]
FloatArrayfloatArrayOf(1.2, 5.0)float[]
IntArrayintArrayOf(1, 2, 3)int[]
LongArraylongArrayOf(1, 2, 3)long[]
ShortArrayshortArrayOf(1, 2, 3)short[]