<div dir="ltr" style="text-align: justify;" trbidi="on">The <b><i>Map </i></b>interface is not an extension of <i><b>Collection </b></i>interface. Instead the interface starts of it’s own interface hierarchy, for maintaining key-value associations. The interface describes a mapping from keys to values, without duplicate keys, by definition.</p>
<p>The Map interface provides three collection views, which allow a map&#8217;s contents to be viewed as a set of keys, collection of values, or set of key-value mappings. The order of a map is defined as the order in which the iterators on the map&#8217;s collection views return their elements. Some map implementations, like the <i><b>TreeMap </b></i>class, make specific guarantees as to their order; others, like the <i><b>HashMap </b></i>class, do not. ;<br />
 ;</p>
<div align="center" id="ads-id"></div>
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="mso-cellspacing: 0in; mso-padding-alt: 2.25pt 2.25pt 2.25pt 2.25pt; width: 100%px;">
<tbody>
<tr style="mso-yfti-irow: 0;">
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 1.0%;" valign="top" width="1%">
<div align="right" class="MsoNormal" style="text-align: right;"> ;void </div>
</td>
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt;">
<div class="MsoNormal"><b>clear</b>() <br />
Removes all mappings from this map (optional operation). </div>
</td>
</tr>
<tr style="mso-yfti-irow: 1;">
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 1.0%;" valign="top" width="1%">
<div align="right" class="MsoNormal" style="text-align: right;"> ;boolean </div>
</td>
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt;">
<div class="MsoNormal"><b>containsKey</b>(Object ;key) <br />
Returns true if this map contains a mapping for the specified key. </div>
</td>
</tr>
<tr style="mso-yfti-irow: 2;">
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 1.0%;" valign="top" width="1%">
<div align="right" class="MsoNormal" style="text-align: right;"> ;boolean </div>
</td>
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt;">
<div class="MsoNormal"><b>containsValue</b>(Object ;value) <br />
Returns true if this map maps one or more keys to the specified value. </div>
</td>
</tr>
<tr style="mso-yfti-irow: 3;">
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 1.0%;" valign="top" width="1%">
<div align="right" class="MsoNormal" style="text-align: right;"> ;Set </div>
</td>
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt;">
<div class="MsoNormal"><b>entrySet</b>() <br />
Returns a set view of the mappings contained in this map. </div>
</td>
</tr>
<tr style="mso-yfti-irow: 4;">
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 1.0%;" valign="top" width="1%">
<div align="right" class="MsoNormal" style="text-align: right;"> ;boolean </div>
</td>
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt;">
<div class="MsoNormal"><b>equals</b>(Object ;o) <br />
Compares the specified object with this map for equality. </div>
</td>
</tr>
<tr style="mso-yfti-irow: 5;">
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 1.0%;" valign="top" width="1%">
<div align="right" class="MsoNormal" style="text-align: right;"> ;Object </div>
</td>
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt;">
<div class="MsoNormal"><b>get</b>(Object ;key) <br />
Returns the value to which this map maps the specified key. </div>
</td>
</tr>
<tr style="mso-yfti-irow: 6;">
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 1.0%;" valign="top" width="1%">
<div align="right" class="MsoNormal" style="text-align: right;"> ;int </div>
</td>
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt;">
<div class="MsoNormal"><b>hashCode</b>() <br />
Returns the hash code value for this map. </div>
</td>
</tr>
<tr style="mso-yfti-irow: 7;">
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 1.0%;" valign="top" width="1%">
<div align="right" class="MsoNormal" style="text-align: right;"> ;boolean </div>
</td>
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt;">
<div class="MsoNormal"><b>isEmpty</b>() <br />
Returns true if this map contains no key-value mappings. </div>
</td>
</tr>
<tr style="mso-yfti-irow: 8;">
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 1.0%;" valign="top" width="1%">
<div align="right" class="MsoNormal" style="text-align: right;"> ;Set </div>
</td>
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt;">
<div class="MsoNormal"><b>keySet</b>() <br />
Returns a set view of the keys contained in this map. </div>
</td>
</tr>
<tr style="mso-yfti-irow: 9;">
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 1.0%;" valign="top" width="1%">
<div align="right" class="MsoNormal" style="text-align: right;"> ;Object </div>
</td>
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt;">
<div class="MsoNormal"><b>put</b>(Object ;key, Object ;value) <br />
Associates the specified value with the specified key in this map (optional operation). </div>
</td>
</tr>
<tr style="mso-yfti-irow: 10;">
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 1.0%;" valign="top" width="1%">
<div align="right" class="MsoNormal" style="text-align: right;"> ;void </div>
</td>
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt;">
<div class="MsoNormal"><b>putAll</b>(Map ;t) <br />
Copies all of the mappings from the specified map to this map (optional operation). </div>
</td>
</tr>
<tr style="mso-yfti-irow: 11;">
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 1.0%;" valign="top" width="1%">
<div align="right" class="MsoNormal" style="text-align: right;"> ;Object </div>
</td>
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt;">
<div class="MsoNormal"><b>remove</b>(Object ;key) <br />
Removes the mapping for this key from this map if it is present (optional operation). </div>
</td>
</tr>
<tr style="mso-yfti-irow: 12;">
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 1.0%;" valign="top" width="1%">
<div align="right" class="MsoNormal" style="text-align: right;"> ;int </div>
</td>
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt;">
<div class="MsoNormal"><b>size</b>() <br />
Returns the number of key-value mappings in this map. </div>
</td>
</tr>
<tr style="mso-yfti-irow: 13; mso-yfti-lastrow: yes;">
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt; width: 1.0%;" valign="top" width="1%">
<div align="right" class="MsoNormal" style="text-align: right;"> ;Collection </div>
</td>
<td style="background: white; padding: 2.25pt 2.25pt 2.25pt 2.25pt;">
<div class="MsoNormal"><b>values</b>() <br />
Returns a collection view of the values contained in this map. </div>
</td>
</tr>
</tbody>
</table>
<p>
The interface methods can be broken down into three sets of operations: altering, querying and providing alternative views</p>
<div class="separator" style="clear: both; text-align: center;"><img border="0" src="https://dineshonjava.com/wp-content/uploads/2013/05/java11.jpg"/></div>
<p>
<b>The alteration operation allows you to add and remove key-value pairs from the map. Both the key and value can be null. However you should not add a Map to itself as a key or value.</b><br />
Object<b> put</b>(Object ;key, Object ;value) <br />
Object <b>remove</b>(Object ;key) <b><br />
</b>void<b> <b> putAll</b>(Map ;t) <br />
</b>void <b> </b><b>clear</b>() </p>
<p><b>The query operations allow you to check on the contents of the map</b><br />
 Object <b>get</b>(Object ;key) <br />
boolean <b>containsKey</b>(Object ;key) <br />
boolean <b>containsValue</b>(Object ;value) <br />
int <b>size</b>()<br />
boolean <b>isEmpty</b>() </p>
<p><b>The set methods allow you to work with the group ofkeys or values as a collection</b><br />
Set<b> keySet</b>() <br />
Collection <b>values</b>() <br />
Set <b>entrySet</b>() </p>
<div style="background-color: #f2f9fc; border-radius: 3px; border: 1px solid #c9e6f2; line-height: 1.45; padding: 16px;">
<b>Java Collections Tutorial</b></p>
<ol style="text-align: left;">
<li><b><a href="https://dineshonjava.com/arraylist-class-in-java-collection/">ArrayList class</a></b></li>
<li><b><a href="https://dineshonjava.com/linkedlist-class-in-collection/">LinkedList class</a></b></li>
<li><b><a href="https://dineshonjava.com/listiterator-interface-in-collection/">ListIterator interface</a></b></li>
<li><b><a href="https://dineshonjava.com/hashset-class-in-collection/">HashSet class</a></b></li>
<li><b><a href="https://dineshonjava.com/linkedhashset-class-in-collection/">LinkedHashSet class</a></b></li>
<li><b><a href="https://dineshonjava.com/treeset-classin-collection/">TreeSet class</a></b></li>
<li><b><a href="https://dineshonjava.com/difference-between-hashset-and-treeset/">Difference between TreeSet &; HashSet</a></b></li>
<li><b><a href="https://dineshonjava.com/hashmap-class-in-collection-framework/">HashMap class</a></b></li>
<li><b><a href="https://dineshonjava.com/how-does-java-hashmap-work-internally/">How does work HashMap?</a> </b></li>
<li><b><a href="https://dineshonjava.com/difference-between-treemap-vs-hashmap/">Difference between TreeMap vs HashMap</a></b></li>
<li><b><a href="https://dineshonjava.com/linkedhashmap-class-in-collection/">LinkedHashMap class</a></b></li>
<li><b><a href="https://dineshonjava.com/treemap-class-in-collection-framework/">TreeMap class</a></b></li>
<li><b><a href="https://dineshonjava.com/hashtable-class-in-collection-framework/">Hashtable class</a></b></li>
<li><b><a href="https://dineshonjava.com/difference-between-hashmap-and/">Difference between HashMap and HashTable in Java</a></b></li>
<li><b><a href="https://dineshonjava.com/sorting-in-collection-framework/">Sorting</a></b></li>
<li><b><a href="https://dineshonjava.com/java-comparable-and-comparator/">Comparable interface</a></b></li>
</ol>
</div>
<p></p>
<div style="background-color: pink; border-width: thin; text-align: center;"><b><;<;<a href="https://dineshonjava.com/difference-between-hashset-and-treeset/">Previous</a> <;<; ; ; || <a href="https://dineshonjava.com/core-java-baby-step-to-be-best-java-ian/">Index </a>||  ; >;>;<a href="https://dineshonjava.com/hashmap-class-in-collection-framework/">Next</a> >;>;</b></div>
<p>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/difference-between-hashset-and-treeset/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/hashmap-class-in-collection-framework/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '460'});
});
</script>
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…