import java.util.*;
public class demo1
{
public static void main(String args[])
{
HashMap<Integer,String> hashmap= new HashMap<Integer,String>();
hashmap.put(1, "C#");
hashmap.put(2, "C++");
hashmap.put(3, "Java");
hashmap.put(4, "Python");
hashmap.put(5, "Ruby");
System.out.println("Elements of hash map: "+hashmap);
System.out.println("Size of the hash map: "+hashmap.size());
}
}Java
Program to count the number of key-value in a hash map.

Written by
View ProfileNikhil Juneja
Passionate software developer and technical contributor at TutorialsLink.
