Immutability is one of the key principles of modern programming languages. So, it's obvious that Kotlin also has immutability implementation. Because of this, Kotlin's collections package has treated immutable data structures as first-class citizens. A few examples might make you understand this more:
val days = listOf("Sunday", "Monday", "Tuesday", "Wednesday")
val months = arrayListOf("January", "February", "March", "April")
In the preceding snippet, days is an immutable list whereas months is a mutable one. For example, months.add("May") is a valid statement whereas we cannot add an item to the days list. The only way to do so is to get a new list out of the existing one by adding the new item. Here's the method:
val modifiedDays = days + "...