Lots of documents have indicated the difference between Map and MutableMap in Kotlin, however, I can't seem to find the difference between HashMap and MutableMap. Can they be used interchangeably? Are there any differences in the implementation level of this 2 data structure? Can someone please elaborate.
And as people have pointed out that MutableMap is an interface. Then when I use a map, what's the difference between using mutableMapOf and hashMapOf?
Thanks.
HashMap is an implementation of the interface MutableMap. From the former link:
Hash table based implementation of the
MutableMapinterface.
There can be other implementations, like LinkedHashMap. You can read the documentation at these links to discover which behaviors are common to all MutableMap implementations, and which are specific to HashMap or LinkedHashMap.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With