Map Interface

  • A map is an object that stores associations between keys and values, or key/ value pairs.
  • Given a key, we can find its value; both keys and values are objects.
  • The keys must be unique, but the values whereas others do not.

 

The following interfaces support maps

  1. Map interface
  2. Map. Entry interface
  3. Sorted Map interface

 

The map interface:

The map interface maps unique keys to values. A key is an object that we use to retrieve a value at a later date. Given a key and a value, we can store the value in the map object. After the value is sorted, we can retrieve it by using its key.

 

The following are the methods declared in the map interface.

  1. Void clear ()
  2. Boolean contains key ( object k)
  3. Boolean contains value ( object v)
  4. Set entry set ()
  5. Boolean equals ( object obj)
  6. Object get ( object k)
  7. Int hashcode ()
  8. Boolean is Empty ()
  9. Set key set ()
  10. Object put ( object k, object v)
  11. Void put all ( Map m)
  12. Object remove ( object k)
  13. Int size ()
  14. Collection value ()

 

Map. Entry interface:

The Map.Entry interface makes possible you to occupation through a map entry. The map entrySet ( ) technique confirmed by the Map interface proceeds a Set surround the map entries. Every of these set fundamentals is a Map.Entry object method. The following are the methods declared in the map.entry interface.

Boolean equals ( object obj)

Object get key ()

Object get value ()

Object set value ( object v)

 

Map Interface Homework Help