Arrays of Primitives
suggest changeThese types do not inherit from Array<T> to avoid boxing, however, they have the same attributes and methods.
| Kotlin type | Factory function | JVM type |
|---|---|---|
BooleanArray |
booleanArrayOf(true, false) |
boolean[] |
ByteArray |
byteArrayOf(1, 2, 3) |
byte[] |
CharArray |
charArrayOf('a', 'b', 'c') |
char[] |
DoubleArray |
doubleArrayOf(1.2, 5.0) |
double[] |
FloatArray |
floatArrayOf(1.2, 5.0) |
float[] |
IntArray |
intArrayOf(1, 2, 3) |
int[] |
LongArray |
longArrayOf(1, 2, 3) |
long[] |
ShortArray |
shortArrayOf(1, 2, 3) |
short[] |
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents