Write a program in kotlin to iterate over the following map
hashMapOf(1 to "car", 2 to "bike", 3 to "cycle", 4 to "truck")
Solution:
fun main(args : Array<String>) { var map = hashMapOf(1 to "car", 2 to "bike", 3 to "cycle", 4 to "truck") for ((key, value) in map) { println("Map[$key] = $value") } }
Output:
Map[1] = car Map[2] = bike Map[3] = cycle Map[4] = truck
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Solution:
Output:
Map[1] = car Map[2] = bike Map[3] = cycle Map[4] = truck