No primitives
Kotlin makes no difference between int/Integer
, float/Float
and so on - all these types only exist in their “object variant”.
While in Java, especially when using collections, it is necessary to differentiate between primitives such as int
and the associated object counterpart, such as Integer
, this is not the case with Kotlin.
Here there are (at language level) only the object variants, no primitives.
No performance loss
However, you do not have to worry too much about the alleged performance loss: whenever possible, the compiler internally uses the JVM’s primitives to generate bytecode.
In addition, classes such as IntArray
offer special collections that are mapped directly to the JVM primitives.