如何工作乐趣get(index:Int):Char?

我不明白功能如何工作。 我写数组[1] = str.get(1),当str =“123”。 但编译器写我关于功能错误得到。 我做错了什么?

在Java中,您可以将char存储到int[]而无需强制转换。 在Kotlin中,这是不可能的,你将不得不使用toInt()方法:

 val ints = IntArray(5) val str = "123" ints[1] = str.get(1).toInt()