Junior — Middle
Which interface provides the functionality of a key-value data structure in the standard library?
sobes.tech AI
Answer from AI
In the standard Android library (Java/Kotlin), the data structure functionality similar to key-value is provided by the Map interface. It defines methods for adding, removing, and searching for values by key. For example, in Kotlin, you can use HashMap, which implements the MutableMap interface:
val map: MutableMap<String, Int> = HashMap()
map["key"] = 42
val value = map["key"]