May you use IntArray and an Array is in Kotlin interchangeably?

Technology CommunityCategory: KotlinMay you use IntArray and an Array is in Kotlin interchangeably?
VietMX Staff asked 3 years ago

Array<Int> is an Integer[] under the hood, while IntArray is an int[].

This means that when you put an Int in an Array<Int>, it will always be boxed (specifically, with an Integer.valueOf() call). In the case of IntArray, no boxing will occur, because it translates to a Java primitive array.

So no, we can’t use them interchangeably.