From this two ways of creating a mutable list, why does one allows to add items, other doesn't

When I specify the data type in diamond brackets and create an empty mutable list I can perform add but when I explicitly give the type of a variable I can’t

val names = mutableListOf<String>()
names.add("Rocky")
    
val notNames: List<String> = mutableListOf()
notNames.add("asdas") // ERROR: Method not found

What’s going on under the hood? Enlighten Kotlin newbie

Contrary to java, List is read-only in Kotlin. Its mutable equivalent is MutableList, so you should use it here:

val notNames: MutableList<String> = mutableListOf()
3 Likes