📜  arraylist vs mutablelist kotlin 代码示例

📅  最后修改于: 2022-03-11 14:53:34.034000             🧑  作者: Mango

代码示例1
The only difference between the two is communicating your intent.

When you write val a = mutableListOf(),
you're saying "I want a mutable list, and I don't particularly 
care about the implementation". When you write, instead, val a = ArrayList(), 
you're saying "I specifically want an ArrayList".

In practice, in the current implementation of Kotlin compiling to the JVM,
calling mutableListOf will produce an ArrayList, 
and there's no difference in behaviour: once the list is built,
everything will behave the same.