- A HashMap contains values based on the key. It implements the Map interface and extends AbstractMap class.
- It contains only unique elements.
- It may have one null key and multiple null values.
- It maintains no order.
Hierarchy of HashMap class:
Example of HashMap class:
Output:102 Rahul 100 Amit 101 Vijay
What is difference between HashSet and HashMap?
HashSet contains only values whereas HashMap contains entry(key and value).
No comments:
Post a Comment