Internal Working of Java HashMap 1. Map and HashMap Map is a collection which stores elements as key-value pairs. A map cannot contain duplicate keys and each key can map to at most one value. The Map interface includes methods for basic operations (such as put , get , remove , containsKey , containsValue , size , and empty ), bulk operations (such as putAll and clear ), and collection views (such as keySet , entrySet , and values ). HashMap implements Map interface in java. It is not synchronized and is not thread safe. Here is an example how to use HashMap in java: 1 public static void main(String[] args) throws IOException { 2 3 Map hashMap = new HashMap(); 4 hashMap.put( 11 , "S...
Posts
Showing posts from January, 2019