Javatpoint Logo
Javatpoint Logo

Scala Maps

Map is used to store elements. It stores elements in pairs of key and values. In scala, you can create map by using two ways either by using comma separated pairs or by using rocket operator.

Scala maps Example

In the following example, we have both approaches to create map.


Map(A -> Apple, B -> Ball)
Map(A -> Aple, B -> Ball)
Empty Map: Map()

Scala Map Example: Adding and Removing Elements

You can add and remove new elements in maps. Scala provides you lots of predefined method. You can use them to perform operations on the Maps. In the following example, we have created a new Map.


Map(A -> Apple, B -> Ball, C -> Cat)
Map(A -> Apple, C -> Cat)
Next TopicScala HashMap

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA