Tag Archives: Map interface java

Learn Map Interface in Java with Programming Example

In this chapter you will learn

  • What is Map Interface in Java?
  • Programming Example

What is Map Interface in Java?

Map Interface provides way to store value mapped by unique key. Later this key is used for retrieving data from collection. A map cannot contain duplicate value and each key map at most one value.

Programming Example

import java.util.*;
class Map_Interface
  public static void main(String[] args)
    Map<String,String> mp=new HashMap<String,String>();
    mp.put("Java" , "1");
    mp.put("C#" , "2");
    mp.put("SQL" , "3");


In this programming Example we created a HashMap object and declare it with string type. We added values along with key pair in HashMap object and printed the table.


In this chapter you learned Map Interface in Java. In the next chapter you will learn about HashTable class in Java.