// Read only list
val readOnlyShapes = listOf("triangle", "square", "circle")
println(shapes) // [triangle, square, circle]
// Mutable list with explicit type declaration
val shapes: MutableList<String> = mutableListOf("triangle", "square", "circle")
// Create a read-only view of a mutable list by assigning it to a List
val shapesLocked: List<String> = shapes
// Accessing items in a list by indexing
println("The first item in the list is: ${readOnlyShapes[0]}")
// Checking if an item exists in a list
println("circle" in readOnlyShapes)
// Read-only set
val readOnlyFruit = setOf("apple", "banana", "cherry", "cherry")
// Mutable set with explicit type declaration
val fruit: MutableSet<String> = mutableSetOf("apple", "banana", "cherry", "cherry")
// Create a read-only view of a mutable set by assigning it to a Set
val fruitLocked: Set<String> = fruit
// Adding & removing items from a mutable set
fruit.add("orange")
fruit.remove("banana")
// Checking if an item exists in a set
println("apple" in readOnlyFruit)
// Read-only map
val readOnlyJuiceMenu = mapOf("apple" to 100, "kiwi" to 190, "orange" to 100)
println(readOnlyJuiceMenu) // {apple=100, kiwi=190, orange=100}
// Mutable map with explicit type declaration
val juiceMenu: MutableMap<String, Int> = mutableMapOf("apple" to 100, "kiwi" to 190, "orange" to 100)
// Create a read-only view of a mutable map by assigning it to a Map
val juiceMenuLocked: Map<String, Int> = juiceMenu
// Accessing items in a map by key
println("The value of apple juice is: ${readOnlyJuiceMenu["apple"]}") // 100
println("The value of pineapple juice is: ${readOnlyJuiceMenu["pineapple"]}") // null
// Adding & removing items from a mutable map
juiceMenu["coconut"] = 150 // Add key "coconut" with value 150 to the map
juiceMenu.remove("orange") // Remove key "orange" from the map