🐦 Kotlin
Beginner
What is a Map in Kotlin?
Answer
A Map stores key-value pairs where each key is unique. Create an immutable map with mapOf("a" to 1, "b" to 2) (using the to infix function to create pairs) or a mutable one with mutableMapOf(). Access values with map["key"] (returns nullable) or map.getValue("key") (throws if key is missing). Kotlin maps support forEach { (k, v) -> } destructuring syntax for clean iteration. For Java interoperability, hashMapOf() and linkedMapOf() create explicit HashMap and LinkedHashMap instances.