Home » Scala HashMap

Scala HashMap

HashMap is used to store element. It use hash code to store elements and return a map.


HashMap Example

In this example, we have created a HashMap.

Output:

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

Scala HashMap Example: Adding and Accessing Elements

In the following example, we have created a HashMap. this program add elements and access elements as well.

Output:

A -> Apple  B -> Ball  C -> Cat  Ball  A -> Apple  B -> Ball  C -> Cat  D -> Doll  
Next TopicScala ListMap

You may also like