Sobes.tech
Junior — Middle

Have you had experience using the HashMap data structure in your projects?

sobes.tech AI

Answer from AI

Yes, in my Android projects I have used the HashMap data structure to store key-value pairs when quick access to data by key is needed. For example, for caching query results or mapping identifiers to objects. HashMap provides an average access time of O(1), making it convenient for such tasks.

Example of using HashMap in Kotlin:

val map = HashMap<String, Int>()
map["apple"] = 3
map["banana"] = 5
println(map["apple"]) // Will output 3

This allows for efficient storage and retrieval of data by key.