Map Interface is a part of collections framework. In a Map data is stored in the form of Key and Value pair.
You can relate it with a Bank locker. Where each locker has a key and we can keep something inside the locker. Just compare the locker key with the Map key and the stuff you keep inside the locker is the Map value.
Below is the Hierarchy for Map :
put(..) method is used to Insert a value to the Map.
It is just like creating a new locker in a bank and you get the key of the locker after that
get(..) method is used to get the value from the Map.
It is just like getting your valuables from the bank locker. You already have a key for your bank locker. Now, you need to go to your locker and use the key to get your valuables from it.
remove(..) method is used to delete an existing value from the Map using the key.
It is just like closing your Bank locker. You go to your locker, open it with the key, get your valuables and close it permanently.
keySet() method is used to get all the keys associated to a Map. And if you see the return type, it is of type Set.
It is just like, you being a bank manager, want to get the keys of all locker holders.
entrySet() method is used to get all the keys and values associated to a Map. Even in this case the method returns a Set.
In other words, entrySet() returns all the Entries associated to a Map.
Just for the sake of understanding, just consider it to be like, you being a Bank Manager, want to get all the Keys and also the contents of all the lockers.
containsKey() method is used to check, if a key is present in the Map or not.
containsValue() method is used to check, if a value is present in the Map or not.
isEmpty() method is used to check, if a Map is Empty or not.
size() method tells us the number of Entries present in the Map.
A Key - Value pair in a Map is termed as an Entry. Since, a Map is a group of Key - Value pair, the Entry Interface is defined inside the Map Interface. i.e. An Entry interface cannot exists on its own.
It is used to get the key of a Map Entry.
It is used to get the value of a Map Entry.
It is used to replace the Value of a Map Entry.