Describe a use case where a map can be used.

Consider a scenario where you want to store currency information of many countries in a way that each country represents its currency. This can’t be done by a list as it just stores data but can’t represent.

Key of map can represent a country name and value as currency; this way all combinations can be stored with each other’s references.

Map.put(‘USA’, “US dollar”);

Map.put(‘India’, “INR”);

Map.put(‘Kuwait’, “Kuwaiti dollar”);

About the author

By Rohit

Recent Posts

Recent Comments