{"id":2353,"date":"2018-12-05T23:45:26","date_gmt":"2018-12-05T15:45:26","guid":{"rendered":"https:\/\/damogame.cn:15443\/wordpress\/?p=2353"},"modified":"2018-12-05T23:45:26","modified_gmt":"2018-12-05T15:45:26","slug":"hashmap-%e6%80%8e%e4%b9%88-hash%ef%bc%9f%e5%8f%88%e5%a6%82%e4%bd%95-map%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/i007.cc\/wordpress\/archives\/2353","title":{"rendered":"HashMap \u600e\u4e48 hash\uff1f\u53c8\u5982\u4f55 map\uff1f\u00a0"},"content":{"rendered":"<div class=\"extra ui horizontal list meta-wrap\">\n<div class=\"item\"><\/div>\n<\/div>\n<div class=\"tags\">HashMap\u00a0\u662f Java \u4e2d Map \u7684\u4e00\u4e2a\u5b9e\u73b0\u7c7b\uff0c\u5b83\u662f\u4e00\u4e2a\u53cc\u5217\u7ed3\u6784(\u6570\u636e+\u94fe\u8868)\uff0c\u8fd9\u6837\u7684\u7ed3\u6784\u4f7f\u5f97\u5b83\u7684\u67e5\u8be2\u548c\u63d2\u5165\u6548\u7387\u90fd\u5f88\u9ad8\u3002HashMap \u5141\u8bb8 null \u952e\u548c\u503c\uff0c\u5b83\u7684\u952e\u552f\u4e00\uff0c\u5143\u7d20\u7684\u5b58\u50a8\u65e0\u5e8f\uff0c\u5e76\u4e14\u5b83\u662f\u7ebf\u7a0b\u4e0d\u5b89\u5168\u7684\u3002<\/div>\n<div id=\"articleContent\" class=\"content\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"zoom-in-cursor\" src=\"https:\/\/oscimg.oschina.net\/oscnet\/24e81018b69298cf434a8eb39682070ccc8.jpg\" width=\"795\" height=\"534\" \/><\/p>\n<p>\u7531\u4e8e HashMap \u7684\u8fd9\u4e9b\u7279\u6027\uff0c\u5b83\u5728 Java \u4e2d\u88ab\u5e7f\u6cdb\u5730\u4f7f\u7528\uff0c\u4e0b\u9762\u6211\u4eec\u5c31\u57fa\u4e8e Java 8 \u5206\u6790\u4e00\u4e0b\u00a0HashMap \u7684\u6e90\u7801\u3002<\/p>\n<p><span id=\"OSC_h1_1\"><\/span><\/p>\n<h1 id=\"h1_1\">\u53cc\u5217\u7ed3\u6784\uff1a\u6570\u7ec4+\u94fe\u8868<\/h1>\n<p>\u9996\u5148 HashMap \u662f\u4e00\u4e2a\u53cc\u5217\u7ed3\u6784\uff0c\u5b83\u662f\u4e00\u4e2a\u6563\u5217\u8868\uff0c\u5b58\u50a8\u65b9\u5f0f\u662f\u952e\u503c\u5bf9\u3002 \u5b83\u7ee7\u627f\u4e86 AbstractMap\uff0c\u5b9e\u73b0\u4e86 Map&lt;K,V&gt; Cloneable Serializable \u63a5\u53e3\u3002<\/p>\n<p>HashMap \u7684\u53cc\u5217\u7ed3\u6784\u662f\u6570\u7ec4 Node[]+\u94fe\u8868\uff0c\u6211\u4eec\u77e5\u9053\u6570\u7ec4\u7684\u67e5\u8be2\u5f88\u5feb\uff0c\u4f46\u662f\u4fee\u6539\u5f88\u6162\uff0c\u56e0\u4e3a\u6570\u7ec4\u5b9a\u957f\uff0c\u6240\u4ee5\u6dfb\u52a0\u6216\u8005\u51cf\u5c11\u5143\u7d20\u90fd\u4f1a\u5bfc\u81f4\u6570\u7ec4\u6269\u5bb9\u3002\u800c\u94fe\u8868\u7ed3\u6784\u6070\u6070\u76f8\u53cd\uff0c\u5b83\u7684\u67e5\u8be2\u6162\uff0c\u56e0\u4e3a\u6ca1\u6709\u7d22\u5f15\uff0c\u9700\u8981\u904d\u5386\u94fe\u8868\u67e5\u8be2\u3002\u4f46\u662f\u5b83\u7684\u4fee\u6539\u5f88\u5feb\uff0c\u4e0d\u9700\u8981\u6269\u5bb9\uff0c\u53ea\u9700\u8981\u5728\u9996\u6216\u8005\u5c3e\u90e8\u6dfb\u52a0\u5373\u53ef\u3002HashMap \u6b63\u662f\u5e94\u7528\u4e86\u8fd9\u4e24\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u4ee5\u6b64\u6765\u4fdd\u8bc1\u5b83\u7684\u67e5\u8be2\u548c\u4fee\u6539\u90fd\u6709\u5f88\u9ad8\u7684\u6548\u7387\u3002<\/p>\n<p>HashMap \u5728\u8c03\u7528 put() \u65b9\u6cd5\u5b58\u50a8\u5143\u7d20\u7684\u65f6\u5019\uff0c\u4f1a\u6839\u636e key \u7684 hash \u503c\u6765\u8ba1\u7b97\u5b83\u7684\u7d22\u5f15\uff0c\u8fd9\u4e2a\u7d22\u5f15\u6709\u4ec0\u4e48\u7528\u5462\uff1fHashMap \u4f7f\u7528\u8fd9\u4e2a\u7d22\u5f15\u6765\u5c06\u8fd9\u4e2a\u952e\u503c\u5bf9\u50a8\u5b58\u5230\u5bf9\u5e94\u7684\u6570\u7ec4\u4f4d\u7f6e\uff0c\u6bd4\u5982\u5982\u679c\u8ba1\u7b97\u51fa\u6765\u7684\u7d22\u5f15\u662f n\uff0c\u5219\u5b83\u5c06\u5b58\u50a8\u5728 Node[n] \u8fd9\u4e2a\u4f4d\u7f6e\u3002<\/p>\n<p>HashMap \u5728\u8ba1\u7b97\u7d22\u5f15\u7684\u65f6\u5019\u5c3d\u91cf\u4fdd\u8bc1\u5b83\u7684\u79bb\u6563\uff0c\u4f46\u8fd8\u662f\u4f1a\u6709\u4e0d\u540c\u7684 key \u8ba1\u7b97\u51fa\u6765\u7684\u7d22\u5f15\u662f\u4e00\u6837\u7684\uff0c\u90a3\u4e48\u7b2c\u4e8c\u6b21\u00a0put \u7684\u65f6\u5019\uff0ckey \u5c31\u4f1a\u4ea7\u751f\u51b2\u7a81\u3002HashMap \u7528\u94fe\u8868\u7684\u7ed3\u6784\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u5f53 HashMap \u53d1\u73b0\u5f53\u524d\u7684\u7d22\u5f15\u4e0b\u5df2\u7ecf\u6709\u4e0d\u4e3a null \u7684 Node \u5b58\u5728\u65f6\uff0c\u4f1a\u5728\u8fd9\u4e2a Node \u540e\u9762\u6dfb\u52a0\u65b0\u5143\u7d20\uff0c\u540c\u4e00\u7d22\u5f15\u4e0b\u7684\u5143\u7d20\u5c31\u7ec4\u6210\u4e86\u94fe\u8868\u7ed3\u6784\uff0cNode \u548c Node \u4e4b\u95f4\u5982\u4f55\u8054\u7cfb\u53ef\u4ee5\u770b\u4e0b\u9762 Node \u7c7b\u7684\u6e90\u7801\u5206\u6790\u3002<\/p>\n<p>\u5148\u4e86\u89e3\u4e00\u4e0b HashMap \u91cc\u6570\u7ec4\u7684\u51e0\u4e2a\u53c2\u6570\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">DEFAULT_INITIAL_CAPACITY\uff0c\u9ed8\u8ba4\u521d\u59cb\u957f\u5ea6\uff0c16\uff1a\r\n\r\nstatic final int DEFAULT_INITIAL_CAPACITY = 1 &lt;&lt; 4; \/\/ aka 16\r\nMAXIMUM_CAPACITY\uff0c\u6700\u5927\u957f\u5ea6\uff0c2^30\uff1a\r\n\r\nstatic final int MAXIMUM_CAPACITY = 1 &lt;&lt; 30;\r\nDEFAULT_LOAD_FACTOR\uff0c\u9ed8\u8ba4\u52a0\u8f7d\u56e0\u5b50\uff0c0.75\uff1a\r\n\r\nstatic final float DEFAULT_LOAD_FACTOR = 0.75f;\r\nfinal float loadFactor;\r\nthreshold\uff0c\u9608\u503c\uff0c\u6269\u5bb9\u7684\u4e34\u754c\u503c\uff08capacity * load factor\uff09\r\n\r\nint threshold;<\/pre>\n<p>\u518d\u770b\u770b HashMap \u6784\u9020\u51fd\u6570<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/\/ \u521d\u59cb\u957f\u5ea6 \u52a0\u8f7d\u56e0\u5b50\r\npublic HashMap(int initialCapacity, float loadFactor)\r\npublic HashMap(int initialCapacity)\r\n\r\n\/\/ \u65e0\u53c2\u6784\u9020\r\npublic HashMap()\r\n\/\/ \u521d\u59cb\u5316\u4e00\u4e2aMap\r\npublic HashMap(Map&lt;? extends K, ? extends V&gt; m)<\/pre>\n<p>\u4e0b\u8fb9\u662f\u975e\u5e38\u91cd\u8981\u7684\u4e00\u4e2a\u5185\u90e8\u7c7b Node \uff0c\u5b83\u5b9e\u73b0\u4e86 Map.Entry\uff0cNode \u662f HashMap \u4e2d\u7684\u57fa\u672c\u5143\u7d20\uff0c\u6bcf\u4e2a\u952e\u503c\u5bf9\u90fd\u50a8\u5b58\u5728\u4e00\u4e2a Node \u5bf9\u8c61\u91cc\uff0c Node \u7c7b\u6709\u56db\u4e2a\u6210\u5458\u53d8\u91cf\uff1ahash\u00a0key \u7684\u54c8\u5e0c\u503c\u3001\u952e\u503c\u5bf9 key \u4e0e value\uff0c\u4ee5\u53ca next \u6307\u9488\u3002next \u4e5f\u662f Node \u7c7b\u578b\uff0c\u8fd9\u4e2a Node \u6307\u5411\u7684\u662f\u94fe\u8868\u4e0b\u4e00\u4e2a\u952e\u503c\u5bf9\uff0c\u8fd9\u4e5f\u5c31\u662f\u524d\u6587\u63d0\u5230\u7684 hash \u51b2\u7a81\u65f6 HashMap \u7684\u5904\u7406\u529e\u6cd5\u3002<\/p>\n<p>Node \u7c7b\u5185\u90e8\u5b9e\u73b0\u4e86 Map.Entry \u63a5\u53e3\u4e2d\u7684\u00a0getKey()\u3001getValue() \u7b49\u65b9\u6cd5\uff0c\u6240\u4ee5\u5728\u904d\u5386 Map \u7684\u65f6\u5019\u6211\u4eec\u53ef\u4ee5\u7528 Map.entrySet() \u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">static class Node&lt;K,V&gt; implements Map.Entry&lt;K,V&gt; {\r\n        final int hash; \/\/ \u54c8\u5e0c\u503c\r\n        final K key;\r\n        V value;\r\n        \/\/ \u94fe\u8868\u7ed3\u6784, \u8fd9\u91cc\u7684next\u5c06\u6307\u5411\u94fe\u8868\u7684\u4e0b\u4e00\u4e2aNode\u952e\u503c\u5bf9\r\n        Node&lt;K,V&gt; next; \r\n        Node(int hash, K key, V value, Node&lt;K,V&gt; next) {\r\n            ...\r\n        }\r\n        public final K getKey()        { return key; }\r\n        public final V getValue()      { return value; }\r\n    }<\/pre>\n<p><span id=\"OSC_h3_2\"><\/span><\/p>\n<h3 id=\"h3_2\">HashMap put() \u6d41\u7a0b<\/h3>\n<p><strong>put() \u65b9\u6cd5<\/strong><\/p>\n<p>put() \u4e3b\u8981\u662f\u5c06 key \u548c value \u4fdd\u5b58\u5230 Node \u6570\u7ec4\u4e2d\uff0cHashMap \u6839\u636e key \u7684 hash \u503c\u6765\u786e\u5b9a\u5b83\u7684\u7d22\u5f15\uff0c\u6e90\u7801\u91cc put \u65b9\u6cd5\u5c06\u8c03\u7528\u5185\u90e8\u7684 putVal() \u65b9\u6cd5\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">public V put(K key, V value) {\r\n        return putVal(hash(key), key, value, false, true);\r\n}<\/pre>\n<p>HashMap \u5728 put \u952e\u503c\u5bf9\u7684\u65f6\u5019\u4f1a\u8c03\u7528 hash() \u65b9\u6cd5\u8ba1\u7b97 key \u7684 hash \u503c\uff0chash() \u65b9\u6cd5\u4f1a\u8c03\u7528 Object \u7684 native \u65b9\u6cd5 hashCode() \u5e76\u4e14\u5c06\u8ba1\u7b97\u4e4b\u540e\u7684 hash \u503c\u9ad8\u4f4e\u4f4d\u505a\u5f02\u6216\u8fd0\u7b97\uff0c\u4ee5\u589e\u52a0 hash \u7684\u590d\u6742\u5ea6\u3002\uff08Java \u91cc\u4e00\u4e2a int \u7c7b\u578b\u5360 4 \u4e2a\u5b57\u8282\uff0c\u4e00\u4e2a\u5b57\u8282\u662f 8 bit\uff0c\u6240\u4ee5\u4e0b\u9762\u6e90\u7801\u4e2d\u7684 h \u4e0e h \u53f3\u79fb 16 \u4f4d\u5c31\u76f8\u5f53\u4e8e\u9ad8\u4f4e\u4f4d\u5f02\u6216\uff09<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">static final int hash(Object key) {\r\n        int h;\r\n        return (key == null) ? 0 : (h = key.hashCode()) ^ (h &gt;&gt;&gt; 16);\r\n}\r\n\/\/key.hashCode() \u662fObject\u7c7b\u7684native\u65b9\u6cd5, \u5b9e\u73b0\u662f\u5c06\u5185\u90e8\u5730\u5740\u8f6c\u6362\u6210\u4e00\u4e2ainteger\uff0c \u4f46\u662f\u5e76\u4e0d\u662f\u7531Java\u5b9e\u73b0\u7684\r\npublic native int hashCode();<\/pre>\n<p><strong>putVal() \u65b9\u6cd5<\/strong><\/p>\n<p>\u8fd9\u90e8\u5206\u662f\u4e3b\u8981 put \u7684\u903b\u8f91<\/p>\n<ol>\n<li>\u8ba1\u7b97\u5bb9\u91cf\uff1a\u6839\u636e map \u7684 size \u8ba1\u7b97\u6570\u7ec4\u5bb9\u91cf\u5927\u5c0f\uff0c\u5982\u679c\u5143\u7d20\u6570\u91cf\u4e5f\u5c31\u662f size \u5927\u4e8e\u6570\u7ec4\u5bb9\u91cf \u00d70.75\uff0c\u5219\u5bf9\u6570\u7ec4\u8fdb\u884c\u6269\u5bb9\uff0c\u6269\u5bb9\u5230\u539f\u6765\u7684 2 \u500d\u3002<\/li>\n<li>\u67e5\u627e\u6570\u636e\u7d22\u5f15\uff1a\u6839\u636e key \u7684 hash \u503c\u548c\u6570\u7ec4\u957f\u5ea6\u627e\u5230 Node \u6570\u7ec4\u7d22\u5f15\u3002<\/li>\n<li>\u50a8\u5b58\uff1a\u8fd9\u91cc\u6709\u4ee5\u4e0b\u51e0\u79cd\u60c5\u51b5\uff08\u5047\u8bbe\u8ba1\u7b97\u51fa\u7684 hash \u4e3a i\uff0c\u6570\u7ec4\u4e3a tab\uff0c\u53d8\u91cf\u4ee5\u4ee3\u7801\u4e3a\u4f8b\uff09\n<ol>\n<li>\u5f53\u524d\u7d22\u5f15\u4e3a null\uff0c\u76f4\u63a5 new \u4e00\u4e2a Node \u5e76\u5b58\u5230\u6570\u7ec4\u91cc\uff0ctab[i]=newNode(hash, key, value, null)<\/li>\n<li>\u6570\u7ec4\u4e0d\u4e3a\u7a7a\uff0c\u8fd9\u65f6\u4e24\u4e2a\u5143\u7d20\u7684 hash \u662f\u4e00\u6837\u7684\uff0c\u518d\u8c03\u7528 equals \u65b9\u6cd5\u5224\u65ad key \u662f\u5426\u4e00\u81f4\uff0c\u76f8\u540c\uff0c\u5219\u8986\u76d6\u5f53\u524d\u7684 value\uff0c\u5426\u5219\u7ee7\u7eed\u5411\u4e0b\u5224\u65ad<\/li>\n<li>\u4e0a\u9762\u4e24\u4e2a\u6761\u4ef6\u90fd\u4e0d\u6ee1\u8db3\uff0c\u8bf4\u660e hash \u53d1\u751f\u51b2\u7a81\uff0cJava 8 \u91cc\u5b9e\u73b0\u4e86\u7ea2\u9ed1\u6811\uff0c\u7ea2\u9ed1\u6811\u5728\u8fdb\u884c\u63d2\u5165\u548c\u5220\u9664\u64cd\u4f5c\u65f6\u901a\u8fc7\u7279\u5b9a\u7b97\u6cd5\u4fdd\u6301\u4e8c\u53c9\u67e5\u627e\u6811\u7684\u5e73\u8861\uff0c\u4ece\u800c\u53ef\u4ee5\u83b7\u5f97\u8f83\u9ad8\u7684\u67e5\u627e\u6027\u80fd\u3002\u672c\u7bc7\u4e5f\u662f\u57fa\u4e8e Java 8 \u7684\u6e90\u7801\u8fdb\u884c\u5206\u6790\uff0c\u5728\u8fd9\u91cc HashMap \u4f1a\u5224\u65ad\u5f53\u524d\u6570\u7ec4\u4e0a\u7684\u5143\u7d20 tab[i] \u662f\u5426\u662f\u7ea2\u9ed1\u6811\uff0c\u5982\u679c\u662f\uff0c\u8c03\u7528\u7ea2\u9ed1\u6811\u7684 putTreeVal \u7684 put \u65b9\u6cd5\uff0c\u5b83\u4f1a\u5c06\u65b0\u5143\u7d20\u4ee5\u7ea2\u9ed1\u6811\u7684\u6570\u636e\u7ed3\u6784\u50a8\u5b58\u5230\u6570\u7ec4\u4e2d\u3002<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>\u5982\u679c\u4ee5\u4e0a\u6761\u4ef6\u90fd\u4e0d\u6210\u7acb\uff0c\u8868\u660e tab[i] \u4e0a\u6709\u5176\u5b83\u00a0key \u5143\u7d20\u5b58\u5728\uff0c\u5e76\u4e14\u6ca1\u6709\u8f6c\u6210\u7ea2\u9ed1\u6811\u7ed3\u6784\uff0c\u8fd9\u65f6\u53ea\u9700\u8c03\u7528 tab[i].next \u6765\u904d\u5386\u6b64\u94fe\u8868\uff0c\u627e\u5230\u94fe\u8868\u7684\u5c3e\u7136\u540e\u5c06\u5143\u7d20\u5b58\u5230\u5f53\u524d\u94fe\u8868\u7684\u5c3e\u90e8\u3002<\/p>\n<pre>transient Node&lt;K,V&gt;[] table;\r\nfinal V putVal(int hash, K key, V value, boolean onlyIfAbsent,\r\n            boolean evict) {\r\n Node&lt;K,V&gt;[] tab; Node&lt;K,V&gt; p; int n, i;\r\n \/\/ \u6839\u636e\u5f53\u524d\u7684map size\u8ba1\u7b97\u5bb9\u91cf\u5927\u5c0fcapacity\uff0c \u4e3b\u8981\u5b9e\u73b0\u662f\u5728resize()\u4e2d\u8ba1\u7b97capacity\uff0c\u9700\u8981\u6269\u5bb9\u7684\u65f6\u5019\uff0c \u957f\u5ea6\u5de6\u79fb\u4e00\u4f4d\uff08\u4e8c\u500d\uff09\r\n if ((tab = table) == null || (n = tab.length) == 0)\r\n     n = (tab = resize()).length;\r\n \/\/ \u8fd9\u91cc\u5c31\u662f\u7ecf\u5e38\u8bf4\u7684\u6876\u7ed3\u6784\u4e86\uff0c \u770b\u8fc7HashMap\u4ecb\u7ecd\u7684\u90fd\u77e5\u9053\u5b83\u7684\u5185\u90e8\u6709\u4e0d\u540c\u7684\u6876, \u8fd9\u4e2a\u6876\u5b9e\u9645\u4e0a\u5c31\u662f\u4e00\u4e2a\u94fe\u8868\u7ed3\u6784\r\n \/\/ \u5728\u8fd9\u4e2a\u5730\u65b9\uff0c HashMap\u5148\u5224\u65adkey\u6240\u5c5e\u7684\u6876\u662f\u5426\u5b58\u5728\u3002 (n - 1) &amp; hash \u76f8\u5f53\u4e8e\u8ba1\u7b97\u6876\u7684\u5e8f\u53f7\uff0c \u6839\u636e\u6876\u5e8f\u53f7\u6765\u627e\u5230\u5bf9\u5e94\u7684\u6876\r\n \/\/ \u8fd9\u91cc\u7684table \u662fHashMap\u7684\u6570\u7ec4\uff0c \u6570\u7ec4\u4e3a\u7a7a\u5c31\u65b0\u5efa\u4e00\u4e2a\u6570\u7ec4 newNode(hash, key, value, null)\r\n if ((p = tab[i = (n - 1) &amp; hash]) == null)\r\n     tab[i] = newNode(hash, key, value, null);\r\n else {\r\n     \/\/\u6570\u7ec4\u4e0d\u4e3a\u7a7a\uff0c \u5148\u5224\u65adkey\u662f\u5426\u5b58\u5728\uff0c \u5b58\u5728 \u5c31\u8986\u76d6value\r\n     Node&lt;K,V&gt; e; K k;\r\n     if (p.hash == hash &amp;&amp;\r\n         ((k = p.key) == key || (key != null &amp;&amp; key.equals(k))))\r\n         e = p;\r\n     \/\/ \u5982\u679c\u6b64\u94fe\u8868\u662f\u7ea2\u9ed1\u6811\u7ed3\u6784\uff08TreeNode\uff09\r\n     else if (p instanceof TreeNode)\r\n         e = ((TreeNode&lt;K,V&gt;)p).putTreeVal(this, tab, hash, key, value);\r\n     else {\r\n         \/\/ \u5faa\u73af\u5f53\u524d\u94fe\u8868\uff0c \u627e\u51fap.next\u4e3a\u7a7a\u7684\u4f4d\u7f6e\u5c31\u662f\u94fe\u8868\u7684\u672b\u7aef\uff0c \u6dfb\u52a0\u4e0a\r\n         for (int binCount = 0; ; ++binCount) {\r\n             if ((e = p.next) == null) { \r\n                p.next = newNode(hash, key, value, null);\r\n                 \/\/ \u8fd9\u91cc\u4f1a\u5224\u65ad\u8fd9\u4e2a\u94fe\u8868\u662f\u5426\u9700\u8981\u8f6c\u6362\u4e3a\u7ea2\u9ed1\u6811\u94fe\u8868\r\n                 if (binCount &gt;= TREEIFY_THRESHOLD - 1) \/\/ -1 for 1st\r\n                     treeifyBin(tab, hash);\r\n                 break;\r\n             }\r\n             if (e.hash == hash &amp;&amp;\r\n                 ((k = e.key) == key || (key != null &amp;&amp; key.equals(k))))\r\n                 break;\r\n             p = e;\r\n         }\r\n     }\r\n     if (e != null) { \/\/ existing mapping for key\r\n         V oldValue = e.value;\r\n         if (!onlyIfAbsent || oldValue == null)\r\n             e.value = value;\r\n         afterNodeAccess(e);\r\n         return oldValue;\r\n     }\r\n }\r\n ++modCount;\r\n if (++size &gt; threshold)\r\n     \/\/ put\u4e4b\u540e\uff0c\u5982\u679c\u5143\u7d20\u4e2a\u6570\u5927\u4e8e\u5f53\u524d\u7684\u6570\u7ec4\u5bb9\u91cf\u4e86\uff0c\u8fdb\u884c\u6570\u7ec4\u6269\u5bb9\r\n     resize();\r\n afterNodeInsertion(evict);\r\n return null;\r\n}<\/pre>\n<p><span id=\"OSC_h3_3\"><\/span><\/p>\n<h3 id=\"h3_3\">HashMap \u7684 get()<\/h3>\n<p>get() \u65b9\u6cd5\u4f1a\u8c03\u7528 getNode() \u65b9\u6cd5\uff0c\u8fd9\u662f get() \u7684\u6838\u5fc3\uff0cgetNode() \u65b9\u6cd5\u7684\u4e24\u4e2a\u53c2\u6570\u5206\u522b\u662f hash \u503c\u548c key\u3002<\/p>\n<pre>public V get(Object key) {\r\n        Node&lt;K,V&gt; e;\r\n        return (e = getNode(hash(key), key)) == null ? null : e.value;\r\n    }<\/pre>\n<p>\u8fd9\u91cc\u91cd\u70b9\u6765\u770b getNode() \u65b9\u6cd5\uff0c\u524d\u9762\u8bb2\u5230\u8fc7\uff0cHashMap \u662f\u901a\u8fc7 key \u751f\u6210\u7684 hash \u503c\u6765\u5b58\u50a8\u5230\u6570\u7ec4\u7684\u5bf9\u5e94\u7d22\u5f15\u4e0a\uff0cHashMap \u5728 get \u7684\u65f6\u5019\u4e5f\u662f\u7528\u8fd9\u79cd\u65b9\u5f0f\u6765\u67e5\u627e\u5143\u7d20\u7684\u3002<\/p>\n<ol>\n<li>\u6839\u636e hash \u503c\u548c\u6570\u7ec4\u957f\u5ea6\u627e\u5230 key \u5bf9\u5e94\u7684\u6570\u7ec4\u7d22\u5f15\u3002<\/li>\n<li>\u62ff\u5230\u5f53\u524d\u7684\u6570\u7ec4\u5143\u7d20\uff0c\u4e5f\u5c31\u662f\u8fd9\u4e2a\u94fe\u8868\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20 first\uff0c\u5148\u7528 hash \u548c equals() \u5224\u65ad\u662f\u4e0d\u662f\u7b2c\u4e00\u4e2a\u5143\u7d20\uff0c\u662f\u7684\u8bdd\u76f4\u63a5\u8fd4\u56de\uff0c\u4e0d\u662f\u7684\u8bdd\u7ee7\u7eed\u4e0b\u9762\u7684\u903b\u8f91\u3002<\/li>\n<li>\u4e0d\u662f\u94fe\u8868\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\uff0c\u5224\u65ad\u8fd9\u4e2a\u5143\u7d20 first \u662f\u4e0d\u662f\u7ea2\u9ed1\u6811\uff0c\u5982\u679c\u662f\u8c03\u7528\u7ea2\u9ed1\u6811\u7684 getTreeNode \u65b9\u6cd5\u6765\u67e5\u8be2\u3002<\/li>\n<li>\u5982\u679c\u4e0d\u662f\u7ea2\u9ed1\u6811\u7ed3\u6784\uff0c\u4ece first \u5143\u7d20\u5f00\u59cb\u904d\u5386\u5f53\u524d\u94fe\u8868\uff0c\u76f4\u5230\u627e\u5230\u8981\u67e5\u8be2\u7684\u5143\u7d20\uff0c\u5982\u679c\u6ca1\u6709\u5219\u8fd4\u56de null\u3002<\/li>\n<\/ol>\n<pre>final Node&lt;K,V&gt; getNode(int hash, Object key) {\r\n   \/\/ tab\uff1a HashMap\u7684\u6570\u7ec4\r\n   Node&lt;K,V&gt;[] tab; \r\n   Node&lt;K,V&gt; first, e; \r\n   int n; K k;\r\n   \/\/ \u5224\u65ad\u6570\u7ec4\u4e0d\u4e3a\u7a7a\uff0c \u6876\u4e0d\u4e3a\u7a7a\r\n   if ((tab = table) != null &amp;&amp; (n = tab.length) &gt; 0 &amp;&amp;\r\n       (first = tab[(n - 1) &amp; hash]) != null) {\r\n       \/\/ \u5148\u67e5\u8be2\u6876\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\r\n       if (first.hash == hash &amp;&amp; \/\/ always check first node\r\n           ((k = first.key) == key || (key != null &amp;&amp; key.equals(k))))\r\n           return first;\r\n       \/\/ \u4e0d\u662f\u7b2c\u4e00\u4e2a\u5143\u7d20\r\n       if ((e = first.next) != null) {\r\n           \/\/ \u5982\u679c\u662f\u7ea2\u9ed1\u6811\uff0c \u5219\u7528\u7ea2\u9ed1\u6811\u7684\u65b9\u6cd5\u67e5\u8be2\r\n           if (first instanceof TreeNode)\r\n               return ((TreeNode&lt;K,V&gt;)first).getTreeNode(hash, key);\r\n           \/\/ \u4e0d\u662f\u7ea2\u9ed1\u6811\uff0c \u904d\u5386\u6876\uff0c \u76f4\u5230\u627e\u5230\u5bf9\u5e94\u7684key\uff0c \u8fd4\u56de\r\n           do {\r\n               \/\/ 1. \u5224\u65adhash\u503c\u662f\u5426\u76f8\u7b49\uff1b 2. \u5224\u65adkey\u76f8\u7b49\u3002 \u9632\u6b62hash\u78b0\u649e\u53d1\u751f\r\n               if (e.hash == hash &amp;&amp;\r\n                   ((k = e.key) == key || (key != null &amp;&amp; key.equals(k))))\r\n                   return e;\r\n           } while ((e = e.next) != null);\r\n       }\r\n   }\r\n   return null;\r\n    }<\/pre>\n<p><span id=\"OSC_h3_4\"><\/span><\/p>\n<h3 id=\"h3_4\">\u6570\u7ec4\u6269\u5bb9\u65f6\u518d\u54c8\u5e0c(re-hash)\u7684\u7406\u89e3<\/h3>\n<p>\u524d\u9762\u63d0\u5230\uff0c\u5f53 HashMap \u5728 put \u5143\u7d20\u7684\u65f6\u5019\uff0cHashMap \u4f1a\u8c03\u7528 resize() \u65b9\u6cd5\u6765\u91cd\u65b0\u8ba1\u7b97\u6570\u7ec4\u5bb9\u91cf\uff0c\u6570\u7ec4\u6269\u5bb9\u4e4b\u540e\uff0c\u6570\u7ec4\u957f\u5ea6\u53d1\u751f\u53d8\u5316\u3002\u6211\u4eec\u77e5\u9053 HashMap \u662f\u6839\u636e key \u7684 hash \u548c\u6570\u7ec4\u957f\u5ea6\u8ba1\u7b97\u5143\u7d20\u4f4d\u7f6e\u7684\uff0c\u90a3\u5f53\u6570\u7ec4\u957f\u5ea6\u53d1\u751f\u53d8\u5316\u65f6\uff0c\u5982\u679c\u4e0d\u91cd\u65b0\u8ba1\u7b97\u5143\u7d20\u7684\u4f4d\u7f6e\uff0c\u5f53\u6211\u4eec get \u5143\u7d20\u7684\u65f6\u5019\u5c31\u627e\u4e0d\u5230\u6b63\u786e\u7684\u5143\u7d20\u4e86\uff0c\u6240\u4ee5 HashMap \u5728\u6269\u5bb9\u7684\u540c\u65f6\u4e5f\u91cd\u65b0\u5bf9\u6570\u7ec4\u5143\u7d20\u8fdb\u884c\u4e86\u8ba1\u7b97\u3002<\/p>\n<p>\u8fd9\u65f6\u8fd8\u6709\u4e00\u4e2a\u95ee\u9898\uff0cre-hash \u7684\u65f6\u5019\u540c\u4e00\u4e2a\u6876(bucket)\u4e0a\u7684\u94fe\u8868\u4f1a\u91cd\u65b0\u6392\u5217\u8fd8\u662f\u94fe\u8868\u4ecd\u7136\u5728\u540c\u4e00\u6876\u4e0a\u3002\u5148\u8003\u8651\u4e00\u4e0b\u5f53\u5b83\u6269\u5bb9\u7684\u65f6\u5019\u540c\u4e00\u4e2a\u6876\u4e0a\u7684\u5143\u7d20\u518d\u4e0e\u65b0\u6570\u7ec4\u957f\u5ea6\u505a\u4e0e\u8fd0\u7b97 &amp; \u65f6\uff0c\u53ef\u80fd\u8ba1\u7b97\u51fa\u6765\u7684\u6570\u7ec4\u7d22\u5f15\u4e0d\u540c\u3002\u5047\u5982\u6570\u7ec4\u957f\u5ea6\u662f 16\uff0c\u6269\u5bb9\u540e\u7684\u6570\u7ec4\u957f\u5ea6\u5c06\u662f 32\u3002<\/p>\n<p>\u4e0b\u8fb9\u7528\u4e8c\u8fdb\u5236\u8bf4\u660e\u8fd9\u4e2a\u95ee\u9898\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"zoom-in-cursor\" src=\"https:\/\/oscimg.oschina.net\/oscnet\/ad1f57db783d5b76115ec2c9f5c44595e33.jpg\" width=\"744\" height=\"286\" \/><\/p>\n<p>\u6700\u7ec8\u7684\u7ed3\u679c\u662f 0000 1111\uff0c\u548c\u7528 oldLen \u8ba1\u7b97\u7684\u7ed3\u679c\u4e00\u6837\uff0c\u5176\u5b9e\u770b\u4e0a\u5f0f\u53ef\u4ee5\u53d1\u73b0\u771f\u6b63\u80fd\u6539\u53d8\u7d22\u5f15\u503c\u7684\u662f hash \u7b2c 5 \u4f4d(\u4ece\u53f3\u5411\u5de6)\u4e0a\u7684\u503c\uff0c\u4e5f\u5c31\u662f length \u7684\u6700\u9ad8\u975e\u96f6\u4f4d\uff0c\u6240\u4ee5\uff0c\u540c\u4e00\u4e2a\u94fe\u8868\u4e0a\u7684\u5143\u7d20\u5728\u6269\u5bb9\u540e\uff0c\u5b83\u4eec\u7684\u7d22\u5f15\u53ea\u6709\u4e24\u79cd\u53ef\u80fd\uff0c\u4e00\u79cd\u5c31\u662f\u4fdd\u6301\u539f\u4f4d(\u6700\u9ad8\u975e\u96f6\u4f4d\u662f 0)\uff0c\u53e6\u4e00\u79cd\u5c31\u662f length+ \u539f\u7d22\u5f15 i (\u7b2c\u4e94\u4f4d\u662f 1\uff0c\u7ed3\u679c\u5c31\u76f8\u7b49\u4e8e 25+\u539f\u7d22\u5f15 i\uff0c\u4e5f\u5c31\u662f length+i)\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"zoom-in-cursor\" src=\"https:\/\/oscimg.oschina.net\/oscnet\/bdb0df603680c1530d5db4a404ece715d8d.jpg\" width=\"582\" height=\"117\" \/><\/p>\n<p>\u4e0b\u8fb9\u6240\u793a\u7684 HashMap \u6e90\u7801\u4e2d\u5c31\u662f\u7528\u8fd9\u4e2a\u601d\u8def\u6765 re-hash \u4e00\u4e2a\u6876\u4e0a\u7684\u94fe\u8868\uff0ce.hash &amp; oldCap == 0 \u5224\u65ad hash \u5bf9\u5e94 length \u7684\u6700\u9ad8\u975e 0 \u4f4d\u662f\u5426\u662f 1\uff0c\u662f 1 \u5219\u628a\u5143\u7d20\u5b58\u5728\u539f\u7d22\u5f15\uff0c\u5426\u5219\u5c06\u5143\u7d20\u5b58\u5728 length+\u539f\u7d22\u5f15\u7684\u4f4d\u7f6e\u3002HashMap \u5b9a\u4e49\u4e86\u56db\u4e2a Node \u5bf9\u8c61\uff0clo \u5f00\u5934\u7684\u662f\u4f4e\u4f4d\u7684\u94fe\u8868(\u539f\u7d22\u5f15)\uff0chi \u5f00\u5934\u7684\u662f\u9ad8\u4f4d\u7684\u94fe\u8868(length+\u539f\u7d22\u5f15\uff0c\u6240\u4ee5\u76f8\u5f53\u4e8e\u662f\u65b0 length \u7684\u9ad8\u4f4d)\u3002<\/p>\n<pre>Node&lt;K,V&gt; loHead = null, loTail = null;  \/\/ \u4f4e\u4f4d\u7d22\u5f15\uff08\u539f\u7d22\u5f15\uff09\u4e0a\u7684\u5143\u7d20\r\nNode&lt;K,V&gt; hiHead = null, hiTail = null;  \/\/ \u9ad8\u4f4d\u7d22\u5f15\uff08\u65b0\u7d22\u5f15\uff09\u4e0a\u7684\u5143\u7d20\r\nNode&lt;K,V&gt; next;\r\ndo {\r\n    next = e.next;\r\n    \/\/ \u5224\u65ad\u662f\u5426\u9700\u8981\u653e\u5230\u65b0\u7684\u7d22\u5f15\u4e0a\r\n    if ((e.hash &amp; oldCap) == 0) {\r\n        \/\/ \u6700\u9ad8\u975e\u96f6\u4f4d\u4e0e\u64cd\u4f5c\u7ed3\u679c\u662f0\uff0c\u6269\u5bb9\u540e\u5143\u7d20\u7d22\u5f15\u4e0d\u53d1\u751f\u53d8\u5316\r\n        if (loTail == null)\r\n            loHead = e;\r\n        else\r\n            loTail.next = e;\r\n        loTail = e;\r\n    }\r\n    else {\r\n        \/\/ \u9700\u8981\u5c06\u5143\u7d20\u653e\u5230\u65b0\u7684\u7d22\u5f15\u4e0a\r\n        if (hiTail == null)\r\n            hiHead = e;\r\n        else\r\n            hiTail.next = e;\r\n        hiTail = e;\r\n    }\r\n} while ((e = next) != null);\r\nif (loTail != null) {\r\n    loTail.next = null;\r\n    \/\/ \u8fd9\u90e8\u5206\u7684\u94fe\u8868\u7d22\u5f15\u6ca1\u6709\u53d1\u751f\u53d8\u5316\uff0c\u5c06\u94fe\u8868\u653e\u5230\u539f\u7d22\u5f15\u4e0a\r\n    newTab[j] = loHead;\r\n}\r\nif (hiTail != null) {\r\n    hiTail.next = null;\r\n    \/\/ \u8fd9\u90e8\u5206\u7684\u94fe\u8868\u7d22\u5f15\u53d1\u751f\u53d8\u5316\uff0c\u5c06\u94fe\u8868\u653e\u5230\u65b0\u7d22\u5f15\u4e0a\r\n    newTab[j + oldCap] = hiHead;\r\n}<\/pre>\n<p><span id=\"OSC_h1_5\"><\/span><\/p>\n<h1 id=\"h1_5\">HashMap \u4e0e HashTable<\/h1>\n<p>\u53e6\u5916\u5bf9\u6bd4\u4e00\u4e0b\u00a0HashMap \u4e0e HashTable\uff1a<\/p>\n<ul>\n<li>HashMap \u662f<strong>\u7ebf\u7a0b\u4e0d\u5b89\u5168<\/strong>\u7684\uff0cHashTable \u7ebf\u7a0b\u5b89\u5168\uff0c\u56e0\u4e3a\u5b83\u5728 get\u3001put \u65b9\u6cd5\u4e0a\u52a0\u4e86 synchronized \u5173\u952e\u5b57\u3002<\/li>\n<li>HashMap \u548c HashTable \u7684 hash \u503c\u662f\u4e0d\u4e00\u6837\u7684\uff0c\u6240\u5728\u7684\u6876\u7684\u8ba1\u7b97\u65b9\u5f0f\u4e5f\u4e0d\u4e00\u6837\u3002HashMap \u7684\u6876\u662f\u901a\u8fc7 &amp; \u8fd0\u7b97\u7b26\u6765\u5b9e\u73b0\u00a0(tab.length &#8211; 1) &amp; hash\uff0c\u800c HashTable \u662f\u901a\u8fc7\u53d6\u4f59\u8ba1\u7b97\uff0c\u901f\u5ea6\u66f4\u6162\uff08hash &amp; 0x7FFFFFFF) % tab.length\u00a0\uff08\u5f53 tab.length = 2^n \u65f6\uff0c\u56e0\u4e3a HashMap \u7684\u6570\u7ec4\u957f\u5ea6\u6b63\u597d\u90fd\u662f 2^n\uff0c\u6240\u4ee5\u4e24\u8005\u662f\u7b49\u4ef7\u7684\uff09<\/li>\n<li>HashTable \u7684 synchronized \u662f\u65b9\u6cd5\u7ea7\u522b\u7684\uff0c\u4e5f\u5c31\u662f\u5b83\u662f\u5728 put() \u65b9\u6cd5\u4e0a\u52a0\u7684\uff0c\u8fd9\u4e5f\u5c31\u662f\u8bf4\u4efb\u4f55\u4e00\u4e2a put \u64cd\u4f5c\u90fd\u4f1a\u4f7f\u7528\u540c\u4e00\u4e2a\u9501\uff0c\u800c\u5b9e\u9645\u4e0a\u4e0d\u540c\u7d22\u5f15\u4e0a\u7684\u5143\u7d20\u4e4b\u95f4\u5f7c\u6b64\u64cd\u4f5c\u4e0d\u4f1a\u53d7\u5230\u5f71\u54cd\uff1bConcurrentHashMap\u00a0\u76f8\u5f53\u4e8e\u662f HashTable \u7684\u5347\u7ea7\uff0c\u5b83\u4e5f\u662f\u7ebf\u7a0b\u5b89\u5168\u7684\uff0c\u800c\u4e14\u53ea\u6709\u5728\u540c\u4e00\u4e2a\u6876\u4e0a\u52a0\u9501\uff0c\u4e5f\u5c31\u662f\u8bf4\u53ea\u6709\u5728\u591a\u4e2a\u7ebf\u7a0b\u64cd\u4f5c\u540c\u4e00\u4e2a\u6570\u7ec4\u7d22\u5f15\u7684\u65f6\u5019\u624d\u52a0\u9501\uff0c\u6781\u5927\u63d0\u9ad8\u4e86\u6548\u7387\u3002<\/li>\n<\/ul>\n<p><span id=\"OSC_h1_6\"><\/span><\/p>\n<h1 id=\"h1_6\">\u603b\u7ed3<\/h1>\n<ul>\n<li>HashMap \u5e95\u5c42\u662f<strong>\u6570\u7ec4+\u94fe\u8868<\/strong>\u7ed3\u6784\uff0c\u6570\u7ec4\u957f\u5ea6\u9ed8\u8ba4\u662f 16\uff0c\u5f53\u5143\u7d20\u7684\u4e2a\u6570\u5927\u4e8e\u6570\u7ec4\u957f\u5ea6\u00d70.75 \u65f6\uff0c\u6570\u7ec4\u4f1a\u6269\u5bb9\u3002<\/li>\n<li>HashMap \u662f<strong>\u6563\u5217\u8868<\/strong>\uff0c\u5b83\u6839\u636e key \u7684 hash \u503c\u6765\u627e\u5230\u5bf9\u5e94\u7684\u6570\u7ec4\u7d22\u5f15\u6765\u50a8\u5b58\uff0c \u53d1\u751f hash \u78b0\u649e\u7684\u65f6\u5019\uff08\u8ba1\u7b97\u51fa\u6765\u7684 hash \u503c\u76f8\u7b49\uff09 HashMap \u5c06\u91c7\u7528\u62c9\u94fe\u5f0f\u6765\u50a8\u5b58\u5143\u7d20\uff0c\u4e5f\u5c31\u662f\u6211\u4eec\u6240\u8bf4\u7684\u5355\u5411\u94fe\u8868\u7ed3\u6784\u3002<\/li>\n<li>\u5728 Java7 \u4e2d\uff0c\u5982\u679c hash \u78b0\u649e\uff0c\u5bfc\u81f4\u62c9\u94fe\u8fc7\u957f\uff0c\u67e5\u8be2\u7684\u6027\u80fd\u4f1a\u4e0b\u964d\uff0c \u6240\u4ee5\u5728 Java8 \u4e2d\u6dfb\u52a0<strong>\u7ea2\u9ed1\u6811\u7ed3\u6784<\/strong>\uff0c\u5f53\u4e00\u4e2a\u6876\u7684\u957f\u5ea6\u8d85\u8fc7 8 \u65f6\uff0c\u5c06\u5176\u8f6c\u4e3a\u7ea2\u9ed1\u6811\u94fe\u8868\uff0c\u5982\u679c\u5c0f\u4e8e 6\uff0c\u53c8\u91cd\u65b0\u8f6c\u6362\u4e3a\u666e\u901a\u94fe\u8868\u3002<\/li>\n<li><strong>re-hash\u00a0<\/strong>\u518d\u54c8\u5e0c\u95ee\u9898\uff1aHashMap \u6269\u5bb9\u7684\u65f6\u5019\u4f1a\u91cd\u65b0\u8ba1\u7b97\u6bcf\u4e00\u4e2a\u5143\u7d20\u7684\u7d22\u5f15\uff0c\u91cd\u65b0\u8ba1\u7b97\u4e4b\u540e\u7684\u7d22\u5f15\u53ea\u6709\u4e24\u79cd\u53ef\u80fd\uff0c\u8981\u4e48\u7b49\u4e8e\u539f\u7d22\u5f15\u8981\u4e48\u7b49\u4e8e\u539f\u7d22\u5f15\u52a0\u4e0a\u539f\u6570\u7ec4\u957f\u5ea6\u3002<\/li>\n<li>\u7531\u4e0a\u4e00\u6761\u53ef\u77e5\uff0c\u6bcf\u6b21\u6269\u5bb9\uff0c\u6574\u4e2a hash table \u90fd\u9700\u8981\u91cd\u65b0\u8ba1\u7b97\u7d22\u5f15\uff0c\u975e\u5e38\u8017\u65f6\uff0c\u6240\u4ee5\u5728\u65e5\u5e38\u4f7f\u7528\u4e2d\u4e00\u5b9a\u8981\u6ce8\u610f\u8fd9\u4e2a\u95ee\u9898\u3002<\/li>\n<\/ul>\n<p><span id=\"OSC_h1_7\"><\/span><\/p>\n<h1 id=\"h1_7\">\u53c2\u8003\u6587\u6863<\/h1>\n<ul>\n<li><a href=\"https:\/\/www.quora.com\/Why-is-the-bucket-size-16-by-default-in-HashMap%C2%A0\" rel=\"nofollow\">Why is the bucket size 16 by default in HashMap?\u00a0<\/a><\/li>\n<li><a href=\"https:\/\/www.jianshu.com\/p\/c77ca6fa6097%C2%A0\" rel=\"nofollow\">\u96c6\u5408\u6e90\u7801\u89e3\u6790\u4e4b HashMap(\u57fa\u4e8e Java8)\u00a0<\/a><\/li>\n<li><a href=\"http:\/\/www.importnew.com\/16599.html%C2%A0\" rel=\"nofollow\">Java HashMap \u5de5\u4f5c\u539f\u7406\u00a0<\/a><\/li>\n<li><a href=\"http:\/\/%20https\/\/cloud.tencent.com\/developer\/article\/1113700\" rel=\"nofollow\">HashMap \u6e90\u7801\u8be6\u7ec6\u5206\u6790\uff08JDK1.8\uff09<\/a><\/li>\n<\/ul>\n<p><span id=\"OSC_h1_8\"><\/span><\/p>\n<h1 id=\"h1_8\">\u4f5c\u8005\u4ecb\u7ecd<\/h1>\n<p>\u6a0a\u817e\u98de\uff0c\u6709\u5f00\u6e90\u7cbe\u795e\uff0c\u4e50\u4e8e\u5206\u4eab\uff0c\u5e0c\u671b\u901a\u8fc7\u5199\u535a\u5ba2\u8ba4\u8bc6\u66f4\u591a\u5fd7\u540c\u9053\u5408\u7684\u4eba\u3002\u4e2a\u4eba\u535a\u5ba2\uff1a<a href=\"http:\/\/rollsbean.com\/\" target=\"_blank\" rel=\"nofollow noopener\">rollsbean.com<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>HashMap\u00a0\u662f Java \u4e2d Map<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[],"tags":[119],"class_list":["post-2353","post","type-post","status-publish","format-standard","hentry","tag-03-"],"_links":{"self":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/2353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/comments?post=2353"}],"version-history":[{"count":0,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/2353\/revisions"}],"wp:attachment":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/media?parent=2353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/categories?post=2353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/tags?post=2353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}