package devmanuals.com; import java.util.Map; import java.util.HashMap; public class MapClear { public static void main (String args[]){ Map mp =new HashMap(); //Put value into HashMap mp.put(1,"a"); mp.put(2,"b"); mp.put(3,"c"); mp.put(4,"d"); mp.put(5,"e"); System.out.println("Mappings of map = "+mp); System.out.println("Size of map = "+mp.size()); //implementation of the method. //this method removes all the mappings from the map mp.clear(); System.out.println("Mappings into map after using clear() method :-"+mp); System.out.println("Size of map = "+mp.size()); } }