If you want to store key-value pair as an entry then I would recommend you go for map interface, in map the key must be unique, you can also have duplicate key’s but having duplicate key will not throw any compile time or runtime error, instead of that the old value will be replaced with new value
Some maps supports storing null values as key but it is not recommended ex: Hashmap and LinkedHashMap support’s storing null values as a key but the TreeMap does not support storing null values
The map does not come under collection framework because the collections store only one object but the map stores key-value pair as an entry
You can get the value by simply passing a key to the get() method of map object, if you want to store any value you can use put() method, if you want to read an entry from the map, you need to use Map.Entry interface
Check below examples on HashMap, in the output, the “author4” is not displaying instead of that “author5” is displaying
A technology enthusiast and a professional blogger from India. Through out my IT career, I have had the pleasure of working on various new technologies and built products like www.ziprides.com and some other products. Unfortunately, my attempts have not given me the desired results and as a result, I have finally decided to build a professional blog where I would like to share all my learnings and hoping to learn from other enthusiasts around the world.