size
Returns the number of key/value pairs in the map.
If a map contains more than Int.MAX_VALUE elements, the value of this property is unspecified. For implementations allowing to have more than Int.MAX_VALUE elements, it is recommended to explicitly document behavior of this property.
Since Kotlin
1.3Samples
import kotlin.test.*
import java.util.*
fun main() {
//sampleStart
assertEquals(0, emptyMap<Int, Int>().size)
val mutableMap = mutableMapOf(1 to "one", 2 to "two")
assertEquals(2, mutableMap.size)
mutableMap[3] = "three"
assertEquals(3, mutableMap.size)
//sampleEnd
}