Java Collections

How does java Hashmap work internally

<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;" trbidi&equals;"on"><i><b>What is Hashing&quest;<&sol;b><&sol;i><br &sol;>&NewLine;Hashing in its simplest form&comma; is a way to assigning a unique code for any variable&sol;object after applying any formula&sol;algorithm on its properties&period; A true Hashing function must follow this rule&colon;<&sol;p>&NewLine;<p> Hash function should return the same hash code each and every time&comma; when function is applied on same or equal objects&period; In other words&comma; two equal objects must produce same hash code consistently&period;<&sol;p>&NewLine;<p> <i><b>Note&colon;<&sol;b><&sol;i> All objects in java inherit a default implementation of <b>hashCode&lpar;&rpar;<&sol;b> function defined in Object class&period; This function produce hash code by typically converting the internal address of the object into an integer&comma; thus producing different hash codes for all different objects&period;<&sol;p>&NewLine;<div align&equals;'center' id&equals;"ads-id"><&sol;div>&NewLine;<p><b>HashMap is an array of Entry objects&colon;<&sol;b><br &sol;>&NewLine;Consider HashMap as just an array of objects&period;<&sol;p>&NewLine;<p>Have a look what this Object is&colon;<&sol;p>&NewLine;<pre class&equals;"highlight" name&equals;"code">static class Entry&lt&semi;K&comma;V&gt&semi; implements Map&period;Entry&lt&semi;K&comma;V&gt&semi; &lbrace; &NewLine; final K key&semi; &NewLine; V value&semi; &NewLine; Entry&lt&semi;K&comma;V&gt&semi; next&semi; &NewLine; final int hash&semi; &NewLine;&period;&period;&period; &NewLine;&rcub; &NewLine;<&sol;pre>&NewLine;<p>&NewLine;Each Entry object represents key-value pair&period; Field next refers to other Entry object if a bucket has more than 1 Entry&period;<&sol;p>&NewLine;<p> Sometimes it might happen that <i><b>hashCodes <&sol;b><&sol;i>for 2 different objects are the same&period; In this case 2 objects will be saved in one bucket and will be presented as <i><b>LinkedList<&sol;b><&sol;i>&period; The entry point is more recently added object&period; This object refers to other object with next field and so one&period; Last entry refers to null&period;<br &sol;>&NewLine;When you create <i><b>HashMap <&sol;b><&sol;i>with default constructor<&sol;p>&NewLine;<pre class&equals;"highlight" name&equals;"code">HashMap hashMap &equals; new HashMap&lpar;&rpar;&semi; &NewLine;<&sol;pre>&NewLine;<p>Array is gets created with size 16 and default 0&period;75 load balance&period;<&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img border&equals;"0" src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2013&sol;06&sol;Hash&lowbar;Map3&period;jpg" title&equals;"How does java Hashmap work internally"&sol;><&sol;div>&NewLine;<p><&sol;p>&NewLine;<div style&equals;"background-color&colon; white&semi; border&colon; 0px none&semi; clear&colon; both&semi; font-family&colon; Arial&comma;'Liberation Sans'&comma;'DejaVu Sans'&comma;sans-serif&semi; font-size&colon; 14px&semi; font-style&colon; normal&semi; font-variant&colon; normal&semi; font-weight&colon; normal&semi; letter-spacing&colon; normal&semi; line-height&colon; 18px&semi; margin&colon; 0px 0px 1em&semi; padding&colon; 0px&semi; text-align&colon; left&semi; text-indent&colon; 0px&semi; text-transform&colon; none&semi; vertical-align&colon; baseline&semi; white-space&colon; normal&semi; word-spacing&colon; 0px&semi; word-wrap&colon; break-word&semi;"><b style&equals;"background-color&colon; transparent&semi; background-position&colon; initial initial&semi; background-repeat&colon; initial initial&semi; border&colon; 0px&semi; font-size&colon; 14px&semi; font-weight&colon; bold&semi; margin&colon; 0px&semi; padding&colon; 0px&semi; vertical-align&colon; baseline&semi;">Adding a new key-value pair<&sol;b><&sol;div>&NewLine;<ol style&equals;"background-color&colon; white&semi; border&colon; 0px none&semi; font-family&colon; Arial&comma;'Liberation Sans'&comma;'DejaVu Sans'&comma;sans-serif&semi; font-size&colon; 14px&semi; font-style&colon; normal&semi; font-variant&colon; normal&semi; font-weight&colon; normal&semi; letter-spacing&colon; normal&semi; line-height&colon; 18px&semi; list-style&colon; decimal outside none&semi; margin&colon; 0px 0px 1em 30px&semi; padding&colon; 0px&semi; text-align&colon; left&semi; text-indent&colon; 0px&semi; text-transform&colon; none&semi; vertical-align&colon; baseline&semi; white-space&colon; normal&semi; word-spacing&colon; 0px&semi;">&NewLine;<li style&equals;"background-color&colon; transparent&semi; background-position&colon; initial initial&semi; background-repeat&colon; initial initial&semi; border&colon; 0px&semi; font-size&colon; 14px&semi; margin&colon; 0px&semi; padding&colon; 0px&semi; vertical-align&colon; baseline&semi; word-wrap&colon; break-word&semi;">Calculate <i><b>hashcode <&sol;b><&sol;i>for the key<&sol;li>&NewLine;<li style&equals;"background-color&colon; transparent&semi; background-position&colon; initial initial&semi; background-repeat&colon; initial initial&semi; border&colon; 0px&semi; font-size&colon; 14px&semi; margin&colon; 0px&semi; padding&colon; 0px&semi; vertical-align&colon; baseline&semi; word-wrap&colon; break-word&semi;">&NewLine;<div style&equals;"background-color&colon; transparent&semi; background-position&colon; initial initial&semi; background-repeat&colon; initial initial&semi; border&colon; 0px&semi; clear&colon; both&semi; font-size&colon; 14px&semi; margin&colon; 0px 0px 1em&semi; padding&colon; 0px&semi; vertical-align&colon; baseline&semi; word-wrap&colon; break-word&semi;">Calculate position&nbsp&semi;hash &percnt; &lpar;arrayLength-1&rpar;&rpar;&nbsp&semi;where element should be placed&lpar;bucket number&rpar;<&sol;div>&NewLine;<&sol;li>&NewLine;<li style&equals;"background-color&colon; transparent&semi; background-position&colon; initial initial&semi; background-repeat&colon; initial initial&semi; border&colon; 0px&semi; font-size&colon; 14px&semi; margin&colon; 0px&semi; padding&colon; 0px&semi; vertical-align&colon; baseline&semi; word-wrap&colon; break-word&semi;">&NewLine;<div style&equals;"background-color&colon; transparent&semi; background-position&colon; initial initial&semi; background-repeat&colon; initial initial&semi; border&colon; 0px&semi; clear&colon; both&semi; font-size&colon; 14px&semi; margin&colon; 0px 0px 1em&semi; padding&colon; 0px&semi; vertical-align&colon; baseline&semi; word-wrap&colon; break-word&semi;">If you try to add a value with a key which has already been saved in <i><b>HashMap<&sol;b><&sol;i>&comma; then value gets overwritten&period;<&sol;div>&NewLine;<&sol;li>&NewLine;<li style&equals;"background-color&colon; transparent&semi; background-position&colon; initial initial&semi; background-repeat&colon; initial initial&semi; border&colon; 0px&semi; font-size&colon; 14px&semi; margin&colon; 0px&semi; padding&colon; 0px&semi; vertical-align&colon; baseline&semi; word-wrap&colon; break-word&semi;">Otherwise element is added to the bucket&period; If bucket has already at least one element &&num;8211&semi; a new one is gets added and placed in the first position in the bucket&period; Its&nbsp&semi;next&nbsp&semi;field refers to the old element&period;<&sol;li>&NewLine;<&sol;ol>&NewLine;<div style&equals;"background-color&colon; white&semi; border&colon; 0px none&semi; clear&colon; both&semi; font-family&colon; Arial&comma;'Liberation Sans'&comma;'DejaVu Sans'&comma;sans-serif&semi; font-size&colon; 14px&semi; font-style&colon; normal&semi; font-variant&colon; normal&semi; font-weight&colon; normal&semi; letter-spacing&colon; normal&semi; line-height&colon; 18px&semi; margin&colon; 0px 0px 1em&semi; padding&colon; 0px&semi; text-align&colon; left&semi; text-indent&colon; 0px&semi; text-transform&colon; none&semi; vertical-align&colon; baseline&semi; white-space&colon; normal&semi; word-spacing&colon; 0px&semi; word-wrap&colon; break-word&semi;"><b style&equals;"background-color&colon; transparent&semi; background-position&colon; initial initial&semi; background-repeat&colon; initial initial&semi; border&colon; 0px&semi; font-size&colon; 14px&semi; font-weight&colon; bold&semi; margin&colon; 0px&semi; padding&colon; 0px&semi; vertical-align&colon; baseline&semi;">Deletion&colon;<&sol;b><&sol;div>&NewLine;<ol style&equals;"background-color&colon; white&semi; border&colon; 0px none&semi; font-family&colon; Arial&comma;'Liberation Sans'&comma;'DejaVu Sans'&comma;sans-serif&semi; font-size&colon; 14px&semi; font-style&colon; normal&semi; font-variant&colon; normal&semi; font-weight&colon; normal&semi; letter-spacing&colon; normal&semi; line-height&colon; 18px&semi; list-style&colon; decimal outside none&semi; margin&colon; 0px 0px 1em 30px&semi; padding&colon; 0px&semi; text-align&colon; left&semi; text-indent&colon; 0px&semi; text-transform&colon; none&semi; vertical-align&colon; baseline&semi; white-space&colon; normal&semi; word-spacing&colon; 0px&semi;">&NewLine;<li style&equals;"background-color&colon; transparent&semi; background-position&colon; initial initial&semi; background-repeat&colon; initial initial&semi; border&colon; 0px&semi; font-size&colon; 14px&semi; margin&colon; 0px&semi; padding&colon; 0px&semi; vertical-align&colon; baseline&semi; word-wrap&colon; break-word&semi;">Calculate <i><b>hashcode <&sol;b><&sol;i>for the given key<&sol;li>&NewLine;<li style&equals;"background-color&colon; transparent&semi; background-position&colon; initial initial&semi; background-repeat&colon; initial initial&semi; border&colon; 0px&semi; font-size&colon; 14px&semi; margin&colon; 0px&semi; padding&colon; 0px&semi; vertical-align&colon; baseline&semi; word-wrap&colon; break-word&semi;">Calculate bucket number &lpar;hash &percnt; &lpar;arrayLength-1&rpar;&rpar;<&sol;li>&NewLine;<li style&equals;"background-color&colon; transparent&semi; background-position&colon; initial initial&semi; background-repeat&colon; initial initial&semi; border&colon; 0px&semi; font-size&colon; 14px&semi; margin&colon; 0px&semi; padding&colon; 0px&semi; vertical-align&colon; baseline&semi; word-wrap&colon; break-word&semi;">Get a reference to the first Entry object in the bucket and by means of equals method iterate over all entries in the given bucket&period; Eventually we will find correct Entry&period; If desired element is not found &&num;8211&semi; return&nbsp&semi;null<&sol;li>&NewLine;<&sol;ol>&NewLine;<p><b>What <i>put&lpar;&rpar;<&sol;i> method actually does&colon;<&sol;b><br &sol;>&NewLine;Before going into <b>put&lpar;&rpar;<&sol;b> method’s implementation&comma; it is very important to learn that instances of <i><b>Entry <&sol;b><&sol;i>class are stored in an array&period; <i><b>HashMap <&sol;b><&sol;i>class defines this variable as&colon;<&sol;p>&NewLine;<pre class&equals;"highlight" name&equals;"code">&sol;&ast;&ast; &NewLine; &ast; The table&comma; resized as necessary&period; Length MUST Always be a power of two&period; &NewLine; &ast;&sol; &NewLine; transient Entry&lbrack;&rsqb; table&semi; &NewLine;<&sol;pre>&NewLine;<p>Now look at code implementation of <i><b>put&lpar;&rpar;<&sol;b><&sol;i> method&colon;<&sol;p>&NewLine;<pre class&equals;"highlight" name&equals;"code">&sol;&ast;&ast; &NewLine; &ast; Associates the specified value with the specified key in this map&period; If the &NewLine; &ast; map previously contained a mapping for the key&comma; the old value is &NewLine; &ast; replaced&period; &NewLine; &ast; &NewLine; &ast; &commat;param key &NewLine; &ast; key with which the specified value is to be associated &NewLine; &ast; &commat;param value &NewLine; &ast; value to be associated with the specified key &NewLine; &ast; &commat;return the previous value associated with &lt&semi;tt&gt&semi;key&lt&semi;&sol;tt&gt&semi;&comma; or &lt&semi;tt&gt&semi;null&lt&semi;&sol;tt&gt&semi; &NewLine; &ast; if there was no mapping for &lt&semi;tt&gt&semi;key&lt&semi;&sol;tt&gt&semi;&period; &lpar;A &lt&semi;tt&gt&semi;null&lt&semi;&sol;tt&gt&semi; return &NewLine; &ast; can also indicate that the map previously associated &NewLine; &ast; &lt&semi;tt&gt&semi;null&lt&semi;&sol;tt&gt&semi; with &lt&semi;tt&gt&semi;key&lt&semi;&sol;tt&gt&semi;&period;&rpar; &NewLine; &ast;&sol; &NewLine; public V put&lpar;K key&comma; V value&rpar; &lbrace; &NewLine; if &lpar;key &equals;&equals; null&rpar; &NewLine; return putForNullKey&lpar;value&rpar;&semi; &NewLine; int hash &equals; hash&lpar;key&period;hashCode&lpar;&rpar;&rpar;&semi; &NewLine; int i &equals; indexFor&lpar;hash&comma; table&period;length&rpar;&semi; &NewLine; for &lpar;Entry&lt&semi;k &comma; V&gt&semi; e &equals; table&lbrack;i&rsqb;&semi; e &excl;&equals; null&semi; e &equals; e&period;next&rpar; &lbrace; &NewLine; Object k&semi; &NewLine; if &lpar;e&period;hash &equals;&equals; hash &amp&semi;&amp&semi; &lpar;&lpar;k &equals; e&period;key&rpar; &equals;&equals; key &vert;&vert; key&period;equals&lpar;k&rpar;&rpar;&rpar; &lbrace; &NewLine; V oldValue &equals; e&period;value&semi; &NewLine; e&period;value &equals; value&semi; &NewLine; e&period;recordAccess&lpar;this&rpar;&semi; &NewLine; return oldValue&semi; &NewLine; &rcub; &NewLine; &rcub; &NewLine; &NewLine; modCount&plus;&plus;&semi; &NewLine; addEntry&lpar;hash&comma; key&comma; value&comma; i&rpar;&semi; &NewLine; return null&semi; &NewLine; &rcub; &NewLine;<&sol;pre>&NewLine;<p>&NewLine;<b>Lets note down the steps one by one&colon;<&sol;b><&sol;p>&NewLine;<p> <b>Step1-<&sol;b> First of all&comma; key object is checked for null&period; If key is null&comma; value is stored in table&lbrack;0&rsqb; position&period; Because hash code for null is always 0&period;<&sol;p>&NewLine;<p> <b>Step2<&sol;b>&&num;8211&semi; Then on next step&comma; a hash value is calculated using key’s hash code by calling its <b>hashCode&lpar;&rpar;<&sol;b> method&period; This hash value is used to calculate index in array for storing Entry object&period; JDK designers well assumed that there might be some poorly written <i><b>hashCode&lpar;&rpar;<&sol;b><&sol;i> functions that can return very high or low hash code value&period; To solve this issue&comma; they introduced another hash&lpar;&rpar; function&comma; and passed the object’s hash code to this hash&lpar;&rpar; function to bring hash value in range of array index size&period;<&sol;p>&NewLine;<p> <b>Step3- <&sol;b>Now<i><b> indexFor&lpar;hash&comma; table&period;length&rpar;<&sol;b><&sol;i> function is called to calculate exact index position for storing the Entry object&period;<&sol;p>&NewLine;<p> <b>Step4<&sol;b>&&num;8211&semi; Here comes the main part&period; Now&comma; as we know that two unequal objects can have same hash code value&comma; how two different objects will be stored in same array location &lbrack;called bucket&rsqb;&period;<&sol;p>&NewLine;<p>Answer is <b>LinkedList<&sol;b>&period; If you remember&comma; Entry class had an attribute &OpenCurlyDoubleQuote;next”&period; This attribute always points to next object in chain&period; This is exactly the behavior of LinkedList&period;<&sol;p>&NewLine;<p>So&comma; in case of collision&comma; Entry objects are stored in LinkedList form&period; When an Entry object needs to be stored in particular index&comma; HashMap checks whether there is already an entry&quest;&quest; If there is no entry already present&comma; Entry object is stored in this location&period;<&sol;p>&NewLine;<p>If there is already an object sitting on calculated index&comma; its next attribute is checked&period; If it is null&comma; and current Entry object becomes next node in LinkedList&period; If next variable is not null&comma; procedure is followed until next is evaluated as null&period;<&sol;p>&NewLine;<p>What if we add the another value object with same key as entered before&period; Logically&comma; it should replace the old value&period; How it is done&quest; Well&comma; after determining the index position of Entry object&comma; while iterating over LinkedList on calculated index&comma; HashMap calls equals method on key object for each Entry object&period; All these Entry objects in LinkedList will have similar hash code but equals&lpar;&rpar; method will test for true equality&period; If key&period;equals&lpar;k&rpar; will be true then both keys are treated as same key object&period; This will cause the replacing of value object inside Entry object only&period;<&sol;p>&NewLine;<p>In this way&comma; HashMap ensure the uniqueness of keys&period;<&sol;p>&NewLine;<p><b>How <i>get&lpar;&rpar;<&sol;i> methods works internally<&sol;b><br &sol;>&NewLine;Now we have got the idea&comma; how key-value pairs are stored in HashMap&period; Next big question is &colon; what happens when an object is passed in get method of HashMap&quest; How the value object is determined&quest;<&sol;p>&NewLine;<p>Answer we already should know that the way key uniqueness is determined in put&lpar;&rpar; method &comma; same logic is applied in get&lpar;&rpar; method also&period; The moment HashMap identify exact match for the key object passed as argument&comma; it simply returns the value object stored in current Entry object&period;<&sol;p>&NewLine;<p>If no match is found&comma; get&lpar;&rpar; method returns null&period;<&sol;p>&NewLine;<p>Let have a look at code&colon;<&sol;p>&NewLine;<pre class&equals;"highlight" name&equals;"code">&sol;&ast;&ast; &NewLine; &ast; Returns the value to which the specified key is mapped&comma; or &lbrace;&commat;code null&rcub; &NewLine; &ast; if this map contains no mapping for the key&period; &NewLine; &ast; &NewLine; &ast; &lt&semi;p&gt&semi; &NewLine; &ast; More formally&comma; if this map contains a mapping from a key &lbrace;&commat;code k&rcub; to a &NewLine; &ast; value &lbrace;&commat;code v&rcub; such that &lbrace;&commat;code &lpar;key&equals;&equals;null &quest; k&equals;&equals;null &colon; &NewLine; &ast; key&period;equals&lpar;k&rpar;&rpar;&rcub;&comma; then this method returns &lbrace;&commat;code v&rcub;&semi; otherwise it returns &NewLine; &ast; &lbrace;&commat;code null&rcub;&period; &lpar;There can be at most one such mapping&period;&rpar; &NewLine; &ast; &NewLine; &ast; &lt&semi;&sol;p&gt&semi;&lt&semi;p&gt&semi; &NewLine; &ast; A return value of &lbrace;&commat;code null&rcub; does not &lt&semi;i&gt&semi;necessarily&lt&semi;&sol;i&gt&semi; indicate that &NewLine; &ast; the map contains no mapping for the key&semi; it's also possible that the map &NewLine; &ast; explicitly maps the key to &lbrace;&commat;code null&rcub;&period; The &lbrace;&commat;link &num;containsKey &NewLine; &ast; containsKey&rcub; operation may be used to distinguish these two cases&period; &NewLine; &ast; &NewLine; &ast; &commat;see &num;put&lpar;Object&comma; Object&rpar; &NewLine; &ast;&sol; &NewLine; public V get&lpar;Object key&rpar; &lbrace; &NewLine; if &lpar;key &equals;&equals; null&rpar; &NewLine; return getForNullKey&lpar;&rpar;&semi; &NewLine; int hash &equals; hash&lpar;key&period;hashCode&lpar;&rpar;&rpar;&semi; &NewLine; for &lpar;Entry&lt&semi;k &comma; V&gt&semi; e &equals; table&lbrack;indexFor&lpar;hash&comma; table&period;length&rpar;&rsqb;&semi; e &excl;&equals; null&semi; e &equals; e&period;next&rpar; &lbrace; &NewLine; Object k&semi; &NewLine; if &lpar;e&period;hash &equals;&equals; hash &amp&semi;&amp&semi; &lpar;&lpar;k &equals; e&period;key&rpar; &equals;&equals; key &vert;&vert; key&period;equals&lpar;k&rpar;&rpar;&rpar; &NewLine; return e&period;value&semi; &NewLine; &rcub; &NewLine; return null&semi; &NewLine; &rcub; &NewLine;<&sol;pre>&NewLine;<div style&equals;"background-color&colon; &num;f2f9fc&semi; border-radius&colon; 3px&semi; border&colon; 1px solid &num;c9e6f2&semi; line-height&colon; 1&period;45&semi; padding&colon; 16px&semi;">&NewLine;<b>Java Collections Tutorial<&sol;b><&sol;p>&NewLine;<ol style&equals;"text-align&colon; left&semi;">&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;arraylist-class-in-java-collection&sol;">ArrayList class<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;linkedlist-class-in-collection&sol;">LinkedList class<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;listiterator-interface-in-collection&sol;">ListIterator interface<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;hashset-class-in-collection&sol;">HashSet class<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;linkedhashset-class-in-collection&sol;">LinkedHashSet class<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;treeset-classin-collection&sol;">TreeSet class<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;difference-between-hashset-and-treeset&sol;">Difference between TreeSet &amp&semi; HashSet<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;map-interface-in-collection&sol;">Map interface<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;hashmap-class-in-collection-framework&sol;">HashMap class<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;difference-between-treemap-vs-hashmap&sol;">Difference between TreeMap vs HashMap<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;linkedhashmap-class-in-collection&sol;">LinkedHashMap class<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;treemap-class-in-collection-framework&sol;">TreeMap class<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;hashtable-class-in-collection-framework&sol;">Hashtable class<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;difference-between-hashmap-and&sol;">Difference between HashMap and HashTable in Java<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;sorting-in-collection-framework&sol;">Sorting<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;java-comparable-and-comparator&sol;">Comparable interface<&sol;a><&sol;b><&sol;li>&NewLine;<&sol;ol>&NewLine;<&sol;div>&NewLine;<div style&equals;"background-color&colon; pink&semi; border-width&colon; thin&semi; text-align&colon; center&semi;"><b>&lt&semi;&lt&semi;<a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;hashmap-class-in-collection-framework&sol;">Previous<&sol;a> &lt&semi;&lt&semi;&nbsp&semi;&nbsp&semi; &vert;&vert; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;core-java-baby-step-to-be-best-java-ian&sol;">Index <&sol;a>&vert;&vert; &nbsp&semi; &gt&semi;&gt&semi;<a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;linkedhashmap-class-in-collection&sol;">Next<&sol;a> &gt&semi;&gt&semi;<&sol;b><&sol;div>&NewLine;<p>&NewLine;<&sol;div>&NewLine;<div class&equals;"wp-post-navigation"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-pre"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;hashmap-class-in-collection-framework&sol;">Previous<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-next"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;linkedhashmap-class-in-collection&sol;">Next<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;<script type&equals;"text&sol;javascript">&NewLine;jQuery&lpar;document&rpar;&period;ready&lpar;function&lpar;&dollar;&rpar; &lbrace;&NewLine; &dollar;&period;post&lpar;'https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-admin&sol;admin-ajax&period;php'&comma; &lbrace;action&colon; 'mts&lowbar;view&lowbar;count'&comma; id&colon; '413'&rcub;&rpar;&semi;&NewLine;&rcub;&rpar;&semi;&NewLine;<&sol;script>

Dinesh Rajput

Dinesh Rajput is the chief editor of a website Dineshonjava, a technical blog dedicated to the Spring and Java technologies. It has a series of articles related to Java technologies. Dinesh has been a Spring enthusiast since 2008 and is a Pivotal Certified Spring Professional, an author of a book Spring 5 Design Pattern, and a blogger. He has more than 10 years of experience with different aspects of Spring and Java design and development. His core expertise lies in the latest version of Spring Framework, Spring Boot, Spring Security, creating REST APIs, Microservice Architecture, Reactive Pattern, Spring AOP, Design Patterns, Struts, Hibernate, Web Services, Spring Batch, Cassandra, MongoDB, and Web Application Design and Architecture. He is currently working as a technology manager at a leading product and web development company. He worked as a developer and tech lead at the Bennett, Coleman & Co. Ltd and was the first developer in his previous company, Paytm. Dinesh is passionate about the latest Java technologies and loves to write technical blogs related to it. He is a very active member of the Java and Spring community on different forums. When it comes to the Spring Framework and Java, Dinesh tops the list!

Share
Published by
Dinesh Rajput

Recent Posts

Strategy Design Patterns using Lambda

Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…

4 years ago

Decorator Pattern using Lambda

Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…

4 years ago

Delegating pattern using lambda

Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…

4 years ago

Spring Vs Django- Know The Difference Between The Two

Technology has emerged a lot in the last decade, and now we have artificial intelligence;…

4 years ago

TOP 20 MongoDB INTERVIEW QUESTIONS 2022

Managing a database is becoming increasingly complex now due to the vast amount of data…

4 years ago

Scheduler @Scheduled Annotation Spring Boot

Overview In this article, we will explore Spring Scheduler how we could use it by…

4 years ago