Map Interface

Map Interface -

Map Interface is another very essential object in Java.
Need of this object was to map an object with a key.

Map interface is used if you want to relate an object to a unique key.
So we can say, A Map is an object that maps keys to values. The important thing is that Map maintain only unique keys. If you will put same key then Map overrides this key.

you will find only last key with values.
    Map has three way to get values
    1) Get values through the keys
    2) Get Set of Keys and then get values.
    3) Get pair of keys and values.

Set Interface has some methods describes below -

 void clear() -
          Removes all keys and values from your map.
         
 boolean containsKey(Object key) -
           This method is used for returns true if this map has a key for
           the specified key.

 boolean containsValue(Object value) -
          This method is used for returns true if this map has one or more keys to the given value.
         
 Set entrySet() -
          This method is used for returns a set view of the mappings contained in this map.

 boolean equals(Object o) -
          This method is used for Compares the specified object with this map for equality.

 Object get(Object key) -
          This method is used for return the value according to the specified key.

 int hashCode() -
          It returns the hash code value for this map.

 boolean isEmpty() -
          This method is used for returns true if this map contains no key-value mappings.

 Set keySet() -
          This method is used for returns a set view of the keys contained in this map.

 Object put(Object key, Object value) -
        This method is used for add key value pair in the map.

 void putAll(Map t) -
        This method is used for add all entries of Map t in the map. 

 Object remove(Object key) -
        This method is used for remove the Map entry set form the Set

 int size() -
     This method is used for find the size of the Map.

 Collection values() -
          Returns a collection view of the values contained in this map.
        
There are some classes which implements Map Interface

1.AbstractMap
2.Attributes
3.HashMap
4.Hashtable
5.IdentityHashMap
6.RenderingHints
7.TreeMap
8.WeakHashMap

Comments

Recent Post

Recent Posts Widget

Popular posts from this blog

Capture image from webcam java code, examples

Use of req.query, req.params and req.body in NODE JS

How to capture finger prints in java