hashMapOf

fun <K, V> hashMapOf(vararg pairs: Pair<K, V>): HashMap<K, V>(source)

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.

Since Kotlin

1.0

Samples

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
}