【发布时间】:2020-08-22 21:41:39
【问题描述】:
这会在线程“main”中产生异常:
java.lang.UnsupportedOperationException: 删除
fun main(args: Array<String>) {
val list = listOf(0, 1, 2, 3, 4, 5, 6, 7, 8);
var record: MutableList<Int>;
record = list as MutableList<Int>;
record.remove(2);
print(record);
}
【问题讨论】:
-
List和MutableList之间存在差异。此外,这不是 Java。分号不是必需的。
标签: kotlin exception mutablelist