HashMap Class
This lesson provides some more detail on the built-in methods of the Hashmap class in Java.
We'll cover the following
HashMap
A HashMap stores items in “key/value” pairs, and you can access them by an index of another type. A HashMap can store different types, including, String
keys and Integer
values.
It contains the following methods:
put() - Used to add keys and values.
get(key) - To access a value in the HashMap using its key.
clear() - To remove all mappings.
containsKey(key) - Returns true if one or more key is mapped to a specified value.
isEmpty() - Returns true if the map contains no key-value mappings.
size() - Returns the number of key-value mappings in the map.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.