I see that Kotlin has ByteArray, ShortArray, IntArray, CharArray, DoubleArray, FloatArray
, which are equivalent to byte[], short[], int[],char[], double[]
use arrayOf, arrayOfNulls, emptyArray
var colors_1: Array<String> = arrayOf("green", "red", "blue")
var colors_2: Array<String?> = arrayOfNulls(3)
var colors_3: Array<String> = emptyArray()
Those types are there so that you can create arrays of the primitives, and not the boxed types. Since String isn't a primitive in Java, you can just use Array<String>
in Kotlin as the equivalent of a Java String[]
.