问题
Is there a difference between a Scala Map and a HashMap? I am using the scala.collection.immutable.HashMap.
回答1:
scala.collection.immutable.Map is the interface for immutable maps while scala.collection.immutable.HashMap is a concrete implementation.
Creating with Map() or 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 scala.collection.immutable.HashMap
来源:https://stackoverflow.com/questions/31685236/scala-map-vs-hashmap