In Java, arrays store primitive types whereas collections store boxed types. In Kotlin, both arrays and collections store boxed type whereas one can use classes like
IntArray
,
ByteArray
, etc. to store primitive data type without boxing.
e
ephemient
12/29/2020, 4:35 AM
Java has both boxed and primitive arrays
ephemient
12/29/2020, 4:38 AM
primitive collections can exist too - e.g. the ones provided by Eclipse Collections for Java - but they're not built in
n
nanodeath
12/29/2020, 4:48 PM
Kotlin has IntArray (unboxed) and Array<Int> (boxed)
Java as int[] (unboxed) and Integer[] (boxed).
collections in both languages are always boxed.