Hashmap Explained
Hashmap Explained
• We create a map, where we pass two kinds of values which are 'key'
and 'value'.
• What are the different types of HashMap?
• HashMap in Java stores the data in (Key, Value) pairs, and you can access
them by an index of another type (e.g. an Integer).
• If you try to insert the duplicate key in HashMap, it will replace the element
of the corresponding key.
HASHMAP IN JAVA
LOAD FACTOR IN HASHMAP IN JAVA
WITH EXAMPLES
JAVA HASHMAP
• Java HashMap class implements the Map interface which allows us to store
key and value pair, where keys should be unique.
• If you try to insert the duplicate key, it will replace the element of the
corresponding key.
• It is easy to perform operations using the key index like updation, deletion, etc.
• HashMap in Java is like the legacy Hashtable class, but it is not synchronized.
• It allows us to store the null elements as well, but there should be only one
null key.
• Java HashMap may have one null key and multiple null values.
• The initial default capacity of Java HashMap class is 16 with a load factor of
0.75.
JAVA HASHMAP EXAMPLE
JAVA HASHMAP EXAMPLE TO
REMOVE() ELEMENTS
Basic Operations on Java HashMap
• Add elements
• Access elements
• Change elements
• Remove elements
NICE REFERENCES YOUTUBE
URLS
• https://youtu.be/udB-dHqS3ng
• https://youtu.be/H62Jfv1DJlU