scala.collection.Map is the interface for immutable maps while
scala.collection.HashMap is a concrete implementation.
Map.empty gives a special empty singleton map, with
Map(a -> b) with up to 4 pairs yields specialized classes for such small maps, and 5 and upwards gives you
HashMap is known as HashMap because it uses a technique called Hashing. Hashing is a technique of converting a large String to small String that represents same String. A shorter value helps in indexing and faster searches.
Some points on HashMap:
Internal Structure of HashMap
Internally HashMap contains an array of Node and a node is represented as a class which contains 4 fields :
HashMap is preferrably used where you want the key values to be unque while storing information.
Hope this helps.
Its hashcode is stored at the season of creation and it shouldn't be determined once more. This makes it an incredible contender for key in a Map and its preparing is quick than other HashMap key objects. This is the reason String is for the most part used Object as HashMap keys. Write My Paper For Me