0 votes
in Kotlin by
May you use IntArray and an Array<Int> is in Kotlin interchangeably?

1 Answer

0 votes
by
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.

Related questions

0 votes
0 votes
asked May 26, 2022 in Kotlin by Robin
0 votes
asked Oct 5, 2021 in Kotlin by rajeshsharma
...