hash
Thanks for your feedback!
Was this page helpful?
Returns an empty new HashMap.
import kotlin.test.* import java.util.* fun main() { //sampleStart val map = hashMapOf<Int, Any?>() println("map.isEmpty() is ${map.isEmpty()}") // true map[1] = "x" map[2] = 1.05 // Now map contains something: println(map) // {1=x, 2=1.05} //sampleEnd }
xxxxxxxxxx
val map = hashMapOf<Int, Any?>()
println("map.isEmpty() is ${map.isEmpty()}") // true
map[1] = "x"
map[2] = 1.05
// Now map contains something:
println(map) // {1=x, 2=1.05}
Returns a new HashMap with the specified contents, given as a list of pairs where the first component is the key and the second is the value.
import kotlin.test.* import java.util.* fun main() { //sampleStart val map: HashMap<Int, String> = hashMapOf(1 to "x", 2 to "y", -1 to "zz") println(map) // {-1=zz, 1=x, 2=y} //sampleEnd }
xxxxxxxxxx
val map: HashMap<Int, String> = hashMapOf(1 to "x", 2 to "y", -1 to "zz")
println(map) // {-1=zz, 1=x, 2=y}
Thanks for your feedback!