Kotlin HashMap tutorial in Hindi

kotlin

#1

Hello Friends,

Watch Kotlin HashMap Tutorial in Hindi and If you have any doubt leave a reply to this topic.

Code of this tutorial:

fun main(args: Array<String>) {

// Create instance of HashMap
// where Key type is Int
// and Value type is String
var class10th = HashMap<Int, String>()

//Store values to HashMap
class10th.put(1, "Anand")
class10th.put(2, "Rahul")
class10th.put(3, "Sita")
class10th[44]= "Geeta"
class10th[3]= "XYZ"

//Get value at key no.3
println(class10th.get(3))

//Get value at key no.3
println(class10th[3])

//Get size of map
println(class10th.size)

//Replace value at key no.3
class10th.replace(3,"Nothing")

//Check if map contains key no. 44
println(class10th.containsKey(44))

//check if map contains value "XYZ"
println(class10th.containsValue("XYZ"))

//For loop in map
for (key in class10th.keys){
    println(class10th[key])
}
}