Table of Contents
If we want to represent group of objects as key- value pairs, then we should go for Map interface. Both key & value are objects only. Duplicated. Each key- value pair is consider as entry. hence a map is consider as a Set of entries. Collection interface mean for individual objects, where as Map interface mean for key- value pairs. Hence there is no relationship between Map & Collection.
Important method in Map interface:-
- Object put ( object key, object value ) to insert one ‘key’ value pair into the Map. if the specified key is already available then it replaces old value with the new value& returns old object. If the specified key is not already available then this entry will be added successful& return null.
- Void PutAll (Map m).
- Object get ( object key ). Returns the value associated with the specified key. If the key is not available then returns null.
- Object remove(object key). It removes the entry associated with the key& returns corresponding value.
- Boolean ContainsKey ( object key );
- Boolean ContainValue (object value);
- Boolean IsEmpty();
- int size();
- Void clear();
- set keySet()
- collection values()
- set entrySet()
Each key value pair is consider as entry. Hence Map is consider as set of entries. without existing Map object,there is no chance of existing entry object. Hence Entry interface define inside Map interface.
object setvalue ( object newObject value)