Scala Map vs HashMap

前端 未结 1 700
半阙折子戏
半阙折子戏 2021-01-04 00:37

Is there a difference between a Scala Map and a HashMap? I am using the scala.collection.immutable.HashMap.

相关标签:
1条回答
  • 2021-01-04 01:12

    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

    0 讨论(0)
提交回复
热议问题