{"id":3408,"date":"2018-11-23T15:17:57","date_gmt":"2018-11-23T07:17:57","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=3408"},"modified":"2018-11-23T15:17:57","modified_gmt":"2018-11-23T07:17:57","slug":"java-%e4%b8%ad%e7%9a%84-hashtable-%e4%b8%ba%e4%bb%80%e4%b9%88%e8%a6%81%e5%b0%8f%e5%86%99%ef%bc%8c%e8%80%8c%e4%b8%8d%e6%98%af%e9%a9%bc%e5%b3%b0%e5%91%bd%e5%90%8d%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=3408","title":{"rendered":"Java \u4e2d\u7684 Hashtable \u4e3a\u4ec0\u4e48\u8981\u5c0f\u5199\uff0c\u800c\u4e0d\u662f\u9a7c\u5cf0\u547d\u540d\uff1f"},"content":{"rendered":"<p>\n\tHashtable \u548c&nbsp;HashMap \u662f\u9762\u8bd5\u4e2d\u5fc5\u95ee\u7684\u4e24\u4e2a\u6570\u636e\u7ed3\u6784\u77e5\u8bc6\u70b9\u3002\u5f88\u591a\u4eba\u62ff\u4ed6\u4eec\u505a\u6bd4\u8f83\uff0c\u4eca\u5929\u6211\u4eec\u5c31\u4e00\u8d77\u6765\u8c08\u8c08&nbsp;Hashtable\uff01\n<\/p>\n<p>\n\t\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u6211\u5148\u6765\u95ee\u4e00\u4e2a\u95ee\u9898\uff0cHashtable \u4e2d\u7684 T \u4e3a\u4ec0\u4e48\u4e0d\u662f\u5927\u5199\u3002\u6211\u767e\u5ea6\u8c37\u6b4c\u4e86\u5f88\u4e45\u90fd\u6ca1\u6709\u5408\u7406\u7684\u7b54\u6848\uff01\u6839\u636e\u56fd\u5916\u7f51\u53cb\u7684\u8bc4\u8bba\u5f97\u77e5\uff0cHashtable \u4e4b\u6240\u4ee5\u6ca1\u6709\u9075\u5faa\u9a7c\u5cf0\u547d\u4ee4\u662f\u56e0\u4e3a\u5f53\u521d\u7684\u7a0b\u5e8f\u5458\u4e66\u5199\u65f6\u4ea7\u751f\u7684 bug\uff0c\u540e\u6765\u867d\u7136 sun \u6ce8\u610f\u5230\u4e86\u8fd9\u4e2a\u95ee\u9898\u3002\u4f46\u662f\u8003\u8651\u5230\u5386\u53f2\u517c\u5bb9\u6027\u95ee\u9898\uff0c\u5c31\u9009\u62e9\u4e86\u4fdd\u6301\u539f\u72b6\uff01\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"Java \u4e2d\u7684 Hashtable \u7c7b\u7ed3\u6784\u56fe\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/java-hashtable.png\" style=\"width: 551px;height: 430px\" \/>\n<\/p>\n<p>\n\t\u8bf4\u8d77 Hashtable \u5927\u5bb6\u80fd\u8c08\u5230\u7684\u51e0\u70b9\uff0c\u65e0\u975e\u4e0b\u9762\u51e0\u70b9\uff1a\n<\/p>\n<ul>\n<li>\n\t\t\u76f8\u6bd4&nbsp;HashMap\uff0cHashtable \u662f\u7ebf\u7a0b\u5b89\u5168\u7684\u3002\u56e0\u4e3a&nbsp;Hashtable \u7684\u51e0\u4e2a\u91cd\u8981\u65b9\u6cd5\u90fd\u52a0\u4e0a\u4e86&nbsp;synchronized \u5173\u952e\u5b57\u3002\n\t<\/li>\n<li>\n\t\tHashtable \u7684&nbsp;key\u3001value \u90fd\u4e0d\u53ef\u4ee5\u4e3a null\u3002HashMap \u6700\u591a\u53ea\u5141\u8bb8\u4e00\u6761\u8bb0\u5f55\u7684\u952e\u4e3a null\uff0c\u5141\u8bb8\u591a\u6761\u8bb0\u5f55\u7684\u503c\u4e3a null\u3002\n\t<\/li>\n<li>\n\t\tHashtable&nbsp;\u627f\u81ea Dictionary \u7c7b\uff0cHashMap \u7ee7\u627f\u81ea&nbsp;AbstractMap \u7c7b\u3002\n\t<\/li>\n<li>\n\t\tHashtable \u5df2\u88ab\u6dd8\u6c70\uff0c\u53ef\u4ee5\u4f7f\u7528&nbsp;ConcurrentHashMap \u66ff\u4ee3\uff0c\u8fd9\u4e00\u70b9\u53ef\u4ee5\u5728&nbsp;Hashtable \u6e90\u7801\u4e2d\u7684\u6ce8\u91ca\u8bf4\u660e\u4e2d\u627e\u51fa\u3002\n\t<\/li>\n<li>\n\t\tHashtable\u3001HashMap \u90fd\u4f7f\u7528\u4e86 Iterator\u3002\u800c\u7531\u4e8e\u5386\u53f2\u539f\u56e0\uff0cHashtable \u8fd8\u4f7f\u7528\u4e86 Enumeration \u7684\u65b9\u5f0f\u3002\n\t<\/li>\n<li>\n\t\tHashtable \u76f4\u63a5\u4f7f\u7528\u5bf9\u8c61\u7684 hashCode\u3002\u800c HashMap \u91cd\u65b0\u8ba1\u7b97 hash \u503c\u3002&nbsp;\n\t<\/li>\n<li>\n\t\tHashTable \u4e2d\u7684 hash \u6570\u7ec4\u521d\u59cb\u5927\u5c0f\u662f 11\uff0c\u589e\u52a0\u7684\u65b9\u5f0f\u662f old*2+1\u3002HashMap \u4e2d hash \u6570\u7ec4\u7684\u9ed8\u8ba4\u5927\u5c0f\u662f 16\uff0c\u800c\u4e14\u4e00\u5b9a\u662f 2 \u7684\u6307\u6570\u3002\n\t<\/li>\n<li>\n\t\tHashMap \u6709 containsvalue \u548c containsKey \u4e24\u4e2a\u65b9\u6cd5\uff0cHashtable \u4f7f\u7528\u7684\u662f contains \u65b9\u6cd5\u3002\n\t<\/li>\n<\/ul>\n<p>\n\tHashMap \u5b9e\u73b0\u5927\u591a\u90fd\u662f\u76f8\u540c\u7684\uff0c\u4e5f\u6ca1\u4ec0\u4e48\u53ef\u4ee5\u8bf4\u7684\u3002 \u53ef\u4ee5\u770b\u4f5c\u662f Hashtable \u7684\u8f7b\u91cf\u7ea7\u5b9e\u73b0\u3002\u7531\u4e8e Hashtable \u548c HashMap \u5b9e\u73b0\u5927\u591a\u90fd\u662f\u76f8\u540c\u7684\uff0c\u4e5f\u6ca1\u4ec0\u4e48\u53ef\u4ee5\u8bf4\u7684\u3002\u53e6\u5916 Hashtable \u4e5f\u4e0d\u5728\u88ab\u63a8\u8350\u4f7f\u7528\u4e86\uff0c\u6240\u4ee5\u6211\u5efa\u8bae\u5927\u5bb6\u4e0d\u8981\u5728\u4f7f\u7528\u5b83\uff0c\u6539\u7528 ConcurrentHashMap\u3002\n<\/p>\n<p>\n\t&nbsp;<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=3408\">Java \u4e2d\u7684 Hashtable \u4e3a\u4ec0\u4e48\u8981\u5c0f\u5199\uff0c\u800c\u4e0d\u662f\u9a7c\u5cf0\u547d\u540d\uff1f<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>Hashtable \u548c&nbsp;HashMap \u662f\u9762\u8bd5\u4e2d\u5fc5\u95ee\u7684\u4e24\u4e2a\u6570\u636e\u7ed3\u6784\u77e5\u8bc6\u70b9\u3002\u5f88\u591a\u4eba\u62ff\u4ed6\u4eec\u505a\u6bd4\u8f83\uff0c\u4eca\u5929\u6211 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[1741,1164,1161,1162,426],"class_list":["post-3408","post","type-post","status-publish","format-standard","hentry","category-java","tag-arraylist","tag-concurrenthashmap","tag-hashmap","tag-hashtable","tag-synchronized"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3408","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3408"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3408\/revisions"}],"predecessor-version":[{"id":3409,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3408\/revisions\/3409"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}