We can count the total size of the HashMap using size method in Java. HashMap count the size base number of key exist in HashMap.
HashMap<Integer,String> map = new HashMap<>();
map.put(1,”Selenium”);
map.put(2,”Cypress”);
System.out.println(“Size of the map: ” + map.size()); // Output: 2
sukanya meruva Answered question