Map Interface in Java | Java Collections | Collection Framework | Java Tutorial For Beginners

preview_player
Показать описание
Please use the following link to install the Katalon Studio:

Map:

To represent a group of objects as Key-Value pairs then we should go for Map.
Both Keys and Values are Objects in a Map.
Duplicate Keys are NOT allowed.
Duplicate Values are allowed.
Each Key-Value pair is called an Entry.

Methods defined in Map Interface:

Object put(Object key, Object value): To add a Key-Value pair. If the Key is already available, then old value will be replaced with new value and returns old value.
void putAll(Map m): To add another map.
Object get(Object key): To get the specified Value associated with the Key.
Object remove(Object key): To remove the entry which is associated with the Key.
boolean containsKey(Object key): To verify specified Key available in the Map.
boolean containsValue(Object value): To verify specified value available in the Map.
boolean isEmpty(): To verify Map is empty or not?
int size(): To get the size of the Map.
void clear(): To remove all the elements from the Map.
Set keySet(): To get all the Keys from the Map.
Collection values(Object value): To get all the Values from the Map.
Set entrySet(): To get the entry from the Map.



Рекомендации по теме