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