All About Map Interface in Collection in Java


All About Map Interface in Collection in Java

The Map interface maps unique key elements to their corresponding values.Map interface allows us to view the elements of a collection as set of keys,collection of values and the mapping of key value pair.If we remove a key from the Map, the corresponding value also will be removed.

The method defined in Map interface is given as:


clear();//removes all the mapping from a map.
containsKey(Object key);// returns true if the specified value matches with one or more 
//keys in the Map interface.
containsValue(Object value);// returns true if the specified value matches with one or more 
//values in the Map interface.
entrySet();//returns the key value pair contained in the Map
equals(Object obj);//returns true if the specified object maps with an object of a Map interface.
get(Object key);//returns the value which is mapped to the specified key.
isEmpty();//returns true if a Map contains no key value mapping.
keySet();//returns the keys in a Map.
put(Object key,Object value);Maps the specified key with the value.
putAll();//copies all the specified key value pairs from a specified Map to the Map with which we are 
//currently working
remove(Object key);Removes the specified key from the Map, automatically the value will be removed.
size();//returns the number of key value mapping available in a Map.
 
All About Map Interface in Collection in Java All About Map Interface in Collection in Java Reviewed by Animesh Chatterjee on December 20, 2018 Rating: 5

No comments:

Powered by Blogger.