Home > Java > Code for map interface in java

Code for map interface in java

What is Map

Map is an Interface.In map data is stored in  key-value format.
A map can not contain duplicate Key.We use map if we want to store,update and fetch data on the basis of key.
For Example:
-A map of country and capital
-A map of cities and zip code
-A map of environment variable and their value.

In the below code I am using Hashmap class which implements map interface to store and fetch country name and their capital .

Code

Output

 

 

This Article is TAGGED in . BOOKMARK THE permalink.

Babita Sahu
Automation Software Test Engineer. Skills : Selenium , STLC , Java, Manual Testing , UI / UX Testing

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">