From
val array = intArrayOf(5, 3, 0, 2, 4, 1, 0, 5, 2, 3, 1, 4)
我需要换算成ArrayList<Int>
美元.
I have tried array.toTypedArray()
But it converted to Array<Int>
instead
From
val array = intArrayOf(5, 3, 0, 2, 4, 1, 0, 5, 2, 3, 1, 4)
我需要换算成ArrayList<Int>
美元.
I have tried array.toTypedArray()
But it converted to Array<Int>
instead
您可以使用toCollection
函数并指定ArrayList
作为可变集合来填充:
val arrayList = intArrayOf(1, 2, 5).toCollection(ArrayList())