{"id":4100,"date":"2019-04-09T15:07:33","date_gmt":"2019-04-09T07:07:33","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=4100"},"modified":"2019-04-09T15:07:33","modified_gmt":"2019-04-09T07:07:33","slug":"%e9%9d%a2%e8%af%95%e9%a2%98%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88java%e4%b8%ad%e7%9a%84collection%e7%b1%bb%e9%83%bd%e7%bb%a7%e6%89%bf%e4%ba%86%e6%8a%bd%e8%b1%a1%e7%b1%bb%e8%bf%98%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=4100","title":{"rendered":"\u9762\u8bd5\u9898\uff1a\u4e3a\u4ec0\u4e48Java\u4e2d\u7684Collection\u7c7b\u90fd\u7ee7\u627f\u4e86\u62bd\u8c61\u7c7b\u8fd8\u5b9e\u73b0\u4e86\u62bd\u8c61\u7c7b\u7684\u63a5\u53e3\uff1f"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u6700\u8fd1\u770b\u4e86 Github \u4e0a\u5f88\u706b\u7684\u9879\u76ee\uff0cstar \u8d85\u8fc7\u4e86 vue\u3002\u5c31\u60f3\u770b\u770b github \u7684 star \u6392\u884c\u699c\uff0c\u770b\u5b8c\u4e4b\u540e\uff0c\u6211\u7a81\u7136\u60f3\u5230\u80fd\u4e0d\u80fd\u770b\u770b stackoverflow \u4e0a\u7684\u6392\u884c\u699c\u3002\u505a\u4e00\u4e9b\u7ffb\u8bd1\u4e5f\u5f88\u4e0d\u9519\uff01<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u6253\u5f00 stackoverflow \u7684\u65f6\u5019\uff0c\u7a81\u7136\u770b\u5230\u4e00\u4e2a\u5f88\u7a00\u5947\u7684\u95ee\u9898\u3002\u4e3a\u4ec0\u4e48Java\u4e2d\u7684Collection\u7c7b\u90fd\u7ee7\u627f\u4e86\u62bd\u8c61\u7c7b\u8fd8\u8981\u5b9e\u73b0\u4e86\u62bd\u8c61\u7c7b\u7684\u63a5\u53e3\uff1f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Why do many Collection classes in Java extend the abstract class and implement the interface as well?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u95ee\u9898\uff0c\u662f\u4e00\u4e2a\u6211\u4ece\u6765\u90fd\u6ca1\u6ce8\u610f\u8fc7\u548c\u601d\u8003\u8fc7\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g1we8dqu27j20kv04gmxy.jpg\" alt=\"\" \/><figcaption>stackoverflow \u70ed\u95e8\u95ee\u9898<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5927\u81f4\u7ed9\u5927\u5bb6\u7ffb\u8bd1\u4e00\u4e0b\uff0c\u4e3a\u4ec0\u4e48\u8981\u8fd9\u6837\u505a\uff1f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Java \u4e2d\u5176\u5b9e\u6709\u5f88\u591a\u96c6\u5408 Collection \u90fd\u6709\u8fd9\u6837\u7684\u795e\u64cd\u4f5c\u3002\u6bd4\u5982\uff1aHashSet \u7ee7\u627f\u4e86 AbstractSet \u5e76\u5b9e\u73b0 Set\uff0c\u4f46 AbstractSet \u5df2\u7ecf\u5b9e\u73b0 Set\u3002HashMap extends AbstractMap\uff0cAbstractMap implements Map \u7b49\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e3a\u4ec0\u4e48\u8981\u8fd9\u6837\u505a\u5462\uff1f\u6839\u636e\u4e0a\u9762\u7684\u89e3\u91ca\uff0c\u5176\u4e2d\u4e00\u4e2a\u5f88\u91cd\u8981\u7684\u539f\u56e0\u662f\uff1a\u89c4\u8303\u3002\u5982\u679c\u4e0d\u5b9e\u73b0\u5bf9\u5e94\u7684\u62bd\u8c61\u7c7b\u4e5f\u4e0d\u4f1a\u6709\u5f71\u54cd\uff0c\u53ea\u662f\u5b9e\u73b0\u5bf9\u5e94\u62bd\u8c61\u7c7b\u540e\u80fd\u5e2e\u52a9\u6211\u4eec\u7406\u89e3\u4ee3\u7801\uff0c\u800c\u65e0\u9700\u901a\u8fc7\u7ed9\u5b9a\u7c7b\u7684\u5b8c\u6574\u5c42\u6b21\u7ed3\u6784\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e8c\u4e2a\uff0c\u5728\u53cd\u5c04\u4e0a\u53ef\u4ee5\u89c2\u5bdf\u5230\u5b83\u4eec\u7684\u5dee\u5f02\u3002\u6bd4\u5982\uff0c\u4e0b\u9762\u7684\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for (Class&lt;?&gt; c : ArrayList.class.getInterfaces())\n    System.out.println(c);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd0\u884c\u540e\uff0c\u8f93\u51fa\u4e0b\u9762\u7684\u7ed3\u679c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>interface java.util.List\ninterface java.util.RandomAccess\ninterface java.lang.Cloneable\ninterface java.io.Serializable<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7\u4e0a\u9762\u7684\u7ed3\u679c\uff0c\u4f60\u4f1a\u53d1\u73b0\uff0cList \u5176\u5b9e extends Collection \u63a5\u53e3\uff0c\u4f46\u662f Collection \u63a5\u53e3\u5e76\u6ca1\u88ab\u6253\u5370\u51fa\u6765\u3002\u4e5f\u5c31\u662f\u8bf4\u4e0a\u9762\u7684\u8f93\u51fa\u4e0d\u5305\u62ec\u7531\u8d85\u7c7b\u5b9e\u73b0\u7684\u63a5\u53e3\uff0c\u4e5f\u4e0d\u5305\u62ec\u4f5c\u4e3a\u5305\u542b\u7684\u63a5\u53e3\u7684\u8d85\u63a5\u53e3\u7684\u63a5\u53e3\u3002\u6bd4\u5982\uff0cIterable \u548c Collection \u7b49\u4ece\u4e0a\u9762\u9057\u6f0f\uff0c\u5373\u4f7f ArrayList \u9690\u5f0f\u5b9e\u73b0\u5b83\u4eec\u3002\u8981\u627e\u5230\u5b83\u4eec\uff0c\u60a8\u5fc5\u987b\u9012\u5f52\u8fed\u4ee3\u7c7b\u5c42\u6b21\u7ed3\u6784\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5e78\u8fd0\u7684\u662f\uff0c\u8fd9\u79cd\u5dee\u5f02\u4e0d\u4f1a\u5f71\u54cd instanceof\u3002\u6bd4\u5982 new ArrayList&lt;&gt;() instanceof Iterable \u548c Iterable.class.isAssignableFrom(ArrayList.class) \u7ed3\u679c\u4e3a true\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">JDK \u4e2d\u7684\u8fd9\u4e9b\u96c6\u5408\u7684\u5b9e\u9645\u8bbe\u8ba1\u548c\u5b9e\u73b0\uff0c\u201c\u53ef\u8bfb\u6027\u201d\u4e5f\u662f\u5f88\u91cd\u8981\u7684\u4e00\u90e8\u5206\u3002<\/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=4100\">\u9762\u8bd5\u9898\uff1a\u4e3a\u4ec0\u4e48Java\u4e2d\u7684Collection\u7c7b\u90fd\u7ee7\u627f\u4e86\u62bd\u8c61\u7c7b\u8fd8\u5b9e\u73b0\u4e86\u62bd\u8c61\u7c7b\u7684\u63a5\u53e3\uff1f<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u770b\u4e86 Github \u4e0a\u5f88\u706b\u7684\u9879\u76ee\uff0cstar \u8d85\u8fc7\u4e86 vue\u3002\u5c31\u60f3\u770b\u770b github \u7684 star \u6392\u884c\u699c\uff0c [&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,1161,1779,1743,1166],"class_list":["post-4100","post","type-post","status-publish","format-standard","hentry","category-java","tag-arraylist","tag-hashmap","tag-hashset","tag-linkedlist","tag-vector"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4100","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=4100"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4100\/revisions"}],"predecessor-version":[{"id":4101,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4100\/revisions\/4101"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}