Yes, If you try to update the value of an immutable Map, Scala outputs an error. On the other hand, any changes made in the value of any key in the case of mutable Maps are accepted.
Updating mutable Map:
// Scala map program of
// Updating the values
// in mutable map
// Creating Object
// Main method
val mapMut = scala.collection.mutable.Map("Ajay" -> 30,
"Bhavesh" -> 20,
"Charlie" -> 50)
println("Before Updating: " + mapMut)
mapMut("Ajay") = 10
println("After Updating: " + mapMut)
Before Updating: Map(Ajay -> 30, Charlie -> 50, Bhavesh -> 20)
After Updating: Map(Ajay -> 10, Charlie -> 50, Bhavesh -> 20)
Hope this helps!
If you want to know more about Apache Spark Scala, It's highly recommended to go for Spark certification course today.