Qual é a diferença entre ArrayList<String>() e mutableListOf<String>() em Kotlin?
Olá! Comecei a estudar Kotlin depois de Java e notei que para criar uma lista mutável posso usar duas formas:
```kotlin
val list1: ArrayList = ArrayList()
val list2: MutableList = mutableListOf()
```
Ambas as opções parecem funcionar da mesma forma: posso adicionar, remover e modificar elementos. Mas me confunde que em um caso o tipo é explicitamente `ArrayList`, e no outro é `MutableList`.
Tentei escrever este código:
```kotlin
fun processList(list: MutableList) {
list.add("Kotlin")
}
val arrayList = ArrayList()
val mutableList = mutableListOf()
processList(arrayList) // funciona
processList(mutableList) // também funciona
```
Ambas as listas são passadas para uma função que espera `MutableList`. Então, são a mesma coisa? Ou existem diferenças sutis em desempenho, memória ou comportamento?
Talvez `mutableListOf()` retorne não um `ArrayList`, mas alguma outra implementação? Ou isso é apenas