{"id":359,"date":"2015-04-18T20:51:18","date_gmt":"2015-04-18T12:51:18","guid":{"rendered":"https:\/\/ai.zhousir.top\/?p=359"},"modified":"2026-08-18T12:09:31","modified_gmt":"2026-08-18T04:09:31","slug":"java-%e5%ae%b9%e5%99%a8%ef%bc%9a%e8%ae%a4%e8%af%86%e5%ae%b9%e5%99%a8","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=359","title":{"rendered":"Java \u5bb9\u5668\uff1a\u8ba4\u8bc6\u5bb9\u5668"},"content":{"rendered":"<section id=\"wenyan\" style=\"font-family: system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', Roboto, sans-serif; line-height: 1.75; font-size: 16px; color: #000000; caret-color: #000000;\" data-provider=\"WenYan\">\n<p style=\"margin: 1em 0px;\">\u5bb9\u5668\u662f Java \u5b66\u4e60\u91cc\u5f88\u91cd\u7684\u4e00\u5757\u3002\u521a\u5f00\u59cb\u4f1a\u89c9\u5f97\u96be\uff0c\u7528\u719f\u4e86\u5c31\u987a\u3002\u5bb9\u5668\u7c7b\u4e3b\u8981\u7531\u4e24\u4e2a\u63a5\u53e3\u6d3e\u751f\uff1a<strong style=\"color: #4870ac;\">Collection<\/strong> \u548c <strong style=\"color: #4870ac;\">Map<\/strong>\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u5148\u628a\u4e24\u4e2a\u5bb9\u6613\u6df7\u7684\u540d\u5b57\u5206\u5f00\uff1a<strong style=\"color: #4870ac;\">Collection<\/strong> \u662f\u5bb9\u5668\u5c42\u6b21\u7684\u6839\u63a5\u53e3\uff1b<strong style=\"color: #4870ac;\">Collections<\/strong> \u662f\u4e00\u4e2a\u5de5\u5177\u7c7b\uff0c\u63d0\u4f9b\u5904\u7406\u5bb9\u5668\u7684\u9759\u6001\u65b9\u6cd5\u3002<\/p>\n<p><!--more--><\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e00\u3001Collection vs Collections<\/h2>\n<p style=\"margin: 1em 0px;\">JDK \u4e0d\u63d0\u4f9b Collection \u7684\u76f4\u63a5\u5b9e\u73b0\uff0c\u53ea\u63d0\u4f9b\u66f4\u5177\u4f53\u7684\u5b50\u63a5\u53e3\u5b9e\u73b0\uff08Set\u3001List\uff09\u3002\u90a3 Collection \u63a5\u53e3\u672c\u8eab\u6709\u4ec0\u4e48\u7528\uff1f\u6240\u6709\u901a\u7528\u5bb9\u5668\u90fd\u9075\u5b88\u5b83\uff1a\u5b9e\u73b0\u7c7b\u63d0\u4f9b\u4e24\u4e2a\u300c\u6807\u51c6\u300d\u6784\u9020\u2014\u2014\u65e0\u53c2\u6784\u9020\uff0c\u4ee5\u53ca\u4e00\u4e2a\u53c2\u6570\u7c7b\u578b\u4e3a Collection \u7684\u6784\u9020\uff0c\u7528\u6765\u590d\u5236\u51fa\u4e00\u4efd\u5143\u7d20\u76f8\u540c\u7684\u65b0\u96c6\u5408\u3002\u56e0\u4e3a\u5927\u5bb6\u90fd\u8ba4\u8fd9\u4e2a\u63a5\u53e3\uff0c\u5bb9\u5668\u4e4b\u95f4\u624d\u80fd\u4e92\u76f8\u62f7\u8d1d\u3002<\/p>\n<table style=\"display: table; text-align: left; overflow: auto; border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; overflow-wrap: break-word; word-break: break-all;\" width=\"800\">\n<thead>\n<tr>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u540d\u5b57<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u662f\u4ec0\u4e48<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u4f5c\u7528<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">Collection<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u6839\u63a5\u53e3<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u7edf\u4e00 iterator\u3001add\u3001size\uff1b\u8ba9\u5bb9\u5668\u80fd\u4e92\u76f8\u590d\u5236<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">Collections<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u5de5\u5177\u7c7b<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u9759\u6001\u65b9\u6cd5\uff1a\u540c\u6b65\u5305\u88c5\u3001\u6392\u5e8f\u3001\u4e8c\u5206\u7b49<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">Collections.synchronizedList \u7b49<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u5305\u88c5\u65b9\u6cd5<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u7ed9\u975e\u540c\u6b65\u5b9e\u73b0\u52a0\u4e0a\u540c\u6b65\u5916\u58f3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e8c\u3001Collection \u7684\u7c7b\u5c42\u6b21\u7ed3\u6784<\/h2>\n<p style=\"margin: 1em 0px;\">\u4e0b\u9762\u662f Collection \u4e00\u4fa7\u7684\u5c42\u6b21\u56fe\uff1a<\/p>\n<p style=\"margin: 1em 0px;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone  wp-image-363\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2015\/04\/QQ\u255c\u256a\u2550\u255d20150418205948.png\" alt=\"QQ\u255c\u256a\u2550\u255d20150418205948\" width=\"531\" height=\"310\" \/><\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">Set<\/h3>\n<p style=\"margin: 1em 0px;\">\u4e0d\u542b\u91cd\u590d\u5143\u7d20\uff08\u542b\u53ef\u53d8\u5bf9\u8c61\uff09\u7684 Collection\uff0c\u65e0\u5e8f\u3002\u4e0d\u5305\u542b\u6ee1\u8db3 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">a.equals(b)<\/code> \u7684\u5143\u7d20\u5bf9\uff0c\u6700\u591a\u4e00\u4e2a null\u3002\u5b9e\u73b0\uff1aEnumSet\u3001HashSet\u3001TreeSet \u7b49\u3002<\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">List<\/h3>\n<p style=\"margin: 1em 0px;\">\u6709\u5e8f Collection\uff08\u5e8f\u5217\uff09\uff0c\u5143\u7d20\u53ef\u4ee5\u91cd\u590d\u3002\u901a\u5e38\u5141\u8bb8 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">e1.equals(e2)<\/code> \u7684\u4e00\u5bf9\u5143\u7d20\uff1b\u82e5\u5141\u8bb8 null\uff0c\u901a\u5e38\u5141\u8bb8\u591a\u4e2a null\u3002\u5b9e\u73b0\uff1aArrayList\u3001LinkedList\u3001Vector\u3001Stack \u7b49\u3002<\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">Queue<\/h3>\n<p style=\"margin: 1em 0px;\">\u4e00\u7c7b\u662f<strong style=\"color: #4870ac;\">\u53cc\u7aef\u961f\u5217<\/strong>\uff0c\u5934\u5c3e\u90fd\u80fd\u63d2\u5165\u548c\u79fb\u9664\uff1aArrayDeque\u3001LinkedBlockingDeque\u3001LinkedList\u3002\u53e6\u4e00\u7c7b\u662f<strong style=\"color: #4870ac;\">\u963b\u585e\u961f\u5217<\/strong>\uff0c\u6ee1\u4e86\u518d\u63d2\u4f1a\u629b\u5f02\u5e38\uff1aArrayBlockingQueue\u3001PriorityBlockingQueue\u3001LinkedBlockingQueue\u3002\u63a5\u53e3\u672c\u8eab\u672a\u5fc5\u58f0\u660e\u963b\u585e\u65b9\u6cd5\uff0c\u5b9e\u73b0\u7c7b\u4f1a\u6269\u5c55\u3002<\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e09\u3001Map \u7684\u7c7b\u5c42\u6b21\u7ed3\u6784<\/h2>\n<p style=\"margin: 1em 0px;\">Map \u4e00\u4fa7\u7684\u5c42\u6b21\u56fe\uff1a<\/p>\n<p style=\"margin: 1em 0px;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone  wp-image-364\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2015\/04\/QQ\u255c\u256a\u2550\u255d20150418205934.png\" alt=\"QQ\u255c\u256a\u2550\u255d20150418205934\" width=\"519\" height=\"305\" \/><\/p>\n<p style=\"margin: 1em 0px;\">Map \u662f\u952e\u503c\u5bf9\u96c6\u5408\uff1a\u4e0d\u80fd\u6709\u91cd\u590d\u952e\uff0c\u6bcf\u4e2a\u952e\u6700\u591a\u6620\u5c04\u5230\u4e00\u4e2a\u503c\u3002\u8be5\u63a5\u53e3\u53d6\u4ee3\u4e86 Dictionary \u62bd\u8c61\u7c7b\u3002\u5b9e\u73b0\uff1aHashMap\u3001TreeMap\u3001Hashtable\u3001Properties\u3001EnumMap\u3002<\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u56db\u3001\u5bb9\u5668\u63a5\u53e3\u5c0f\u7ed3<\/h2>\n<p style=\"margin: 1em 0px;\"><img decoding=\"async\" loading=\"lazy\" class=\"\" src=\"http:\/\/www.programcreek.com\/wp-content\/uploads\/2009\/02\/collection-summary.png\" alt=\"collection-summary\" width=\"537\" height=\"158\" data-bd-imgshare-binded=\"1\" \/><\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e94\u3001\u4ee3\u7801\u6837\u4f8b<\/h2>\n<p style=\"margin: 1em 0px;\">HashMap\u3001HashSet\u3001LinkedList\u3001ArrayList\u3001TreeMap\u3001TreeSet \u653e\u5728\u4e00\u8d77\u8dd1\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">import java.util.ArrayList;\n\nimport java.util.HashMap;\n\nimport java.util.HashSet;\n\nimport java.util.LinkedList;\n\nimport java.util.List;\n\nimport java.util.Map;\n\nimport java.util.Set;\n\nimport java.util.TreeMap;\n\nimport java.util.TreeSet;\n\n\n\n@SuppressWarnings(\"unchecked\")\n\npublic class CollectionAll\n\n{\n\n\n\n    public static void main(String[] args)\n\n    {\n\n        printLists();\n\n\n\n        printSets();\n\n\n\n        printMaps();\n\n    }\n\n\n\n    private static void printLists()\n\n    {\n\n        List&lt;String&gt; a1 = new ArrayList&lt;String&gt;();\n\n        a1.add(\"List\");\n\n        a1.add(\"Set\");\n\n        a1.add(\"Queue\");\n\n        a1.add(\"Map\");\n\n        System.out.println(\"ArrayList Elements:\");\n\n        System.out.print(\"\\t\" + a1 + \"\\n\");\n\n\n\n        List&lt;String&gt; l1 = new LinkedList&lt;String&gt;();\n\n        l1.add(\"List\");\n\n        l1.add(\"Set\");\n\n        l1.add(\"Queue\");\n\n        l1.add(\"Map\");\n\n        System.out.println(\"LinkedList Elements:\");\n\n        System.out.print(\"\\t\" + l1 + \"\\n\");\n\n    }\n\n    @SuppressWarnings(\"rawtypes\")\n\n    private static void printSets()\n\n    {\n\n        Set h1 = new HashSet&lt;String&gt;();\n\n        h1.add(\"List\");\n\n        h1.add(\"Set\");\n\n        h1.add(\"Queue\");\n\n        h1.add(\"Map\");\n\n        System.out.println(\"HashSet Elements:\");\n\n        System.out.print(\"\\t\" + h1 + \"\\n\");\n\n\n\n        Set t1 = new TreeSet&lt;String&gt;();\n\n        t1.add(\"List\");\n\n        t1.add(\"Set\");\n\n        t1.add(\"Queue\");\n\n        t1.add(\"Map\");\n\n        System.out.println(\"TreeSet Elements:\");\n\n        System.out.print(\"\\t\" + t1 + \"\\n\");\n\n    }\n\n\n\n    private static void printMaps()\n\n    {\n\n        Map&lt;String, String&gt; h1 = new HashMap&lt;String, String&gt;();\n\n        h1.put(\"List\", \"ArrayList\");\n\n        h1.put(\"Set\", \"HashSet\");\n\n        h1.put(\"Queue\", \"PriorityQueue\");\n\n        h1.put(\"Map\", \"HashMap\");\n\n        System.out.println(\"HashMap Elements:\");\n\n        System.out.print(\"\\t\" + h1 + \"\\n\");\n\n\n\n        Map&lt;String, String&gt; t1 = new TreeMap&lt;String,String&gt;();\n\n        t1.put(\"List\", \"ArrayList\");\n\n        t1.put(\"Set\", \"HashSet\");\n\n        t1.put(\"Queue\", \"PriorityQueue\");\n\n        t1.put(\"Map\", \"HashMap\");\n\n        System.out.println(\"TreeMap Elements:\");\n\n        System.out.print(\"\\t\" + t1 + \"\\n\");\n\n\n\n    }\n\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u63a7\u5236\u53f0\u5927\u81f4\u5982\u4e0b\uff08HashSet \/ HashMap \u65e0\u5e8f\uff0cTreeSet \/ TreeMap \u6309\u952e\u6709\u5e8f\uff09\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">ArrayList Elements:\n[List, Set, Queue, Map]\nLinkedList Elements:\n[List, Set, Queue, Map]\nHashSet Elements:\n[Map, Queue, Set, List]\nTreeSet Elements:\n[List, Map, Queue, Set]\nHashMap Elements:\n{Map=HashMap, Queue=PriorityQueue, Set=HashSet, List=ArrayList}\nTreeMap Elements:\n{List=ArrayList, Map=HashMap, Queue=PriorityQueue, Set=HashSet}<\/code><\/pre>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u516d\u3001\u5e38\u89c1\u5b9e\u73b0\u7684\u5bf9\u6bd4<\/h2>\n<p style=\"margin: 1em 0px;\">\u51fa\u5904\uff1a<a href=\"http:\/\/blog.csdn.net\/softwave\/article\/details\/4166598\" class=\"external\" target=\"_blank\" rel=\"nofollow\" style=\"color: #4870ac; text-decoration: underline;\">http:\/\/blog.csdn.net\/softwave\/article\/details\/4166598<\/a>\u3002<\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">Vector \u548c ArrayList<\/h3>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>Vector \u7ebf\u7a0b\u540c\u6b65\u3001\u5b89\u5168\uff1bArrayList \u5f02\u6b65\u3001\u4e0d\u5b89\u5168\u3002\u4e0d\u8003\u8651\u7ebf\u7a0b\u5b89\u5168\u65f6 ArrayList \u66f4\u5feb\u3002<\/section>\n<\/li>\n<li>\n<section>\u7a7a\u95f4\u4e0d\u591f\u65f6 Vector \u6309\u5f53\u524d\u957f\u5ea6 100% \u6269\uff0cArrayList \u6309 50% \u6269\u3002\u6570\u636e\u91cf\u5f88\u5927\u65f6 Vector \u6269\u5bb9\u6b21\u6570\u53ef\u80fd\u66f4\u5c11\u3002<\/section>\n<\/li>\n<li>\n<section>\u6309\u6307\u5b9a\u4f4d\u7f6e\u67e5\u627e\u4e24\u8005\u90fd\u662f O(1)\u3002\u79fb\u52a8\u6307\u5b9a\u4f4d\u7f6e\u7684\u6570\u636e\u662f O(n\u2212i)\uff0c\u8fd9\u65f6\u66f4\u8be5\u8003\u8651 LinkedList\uff1a\u79fb\u52a8 O(1)\uff0c\u6309\u4f4d\u7f6e\u67e5\u627e O(i)\u3002<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">ArrayList \u548c Vector \u90fd\u7528\u6570\u7ec4\u5b58\u6570\u636e\uff0c\u6570\u7ec4\u5bb9\u91cf\u5927\u4e8e\u5b9e\u9645\u5143\u7d20\u4ee5\u4fbf\u63d2\u5165\u3002\u6309\u5e8f\u53f7\u7d22\u5f15\u5feb\uff0c\u63d2\u5165\u8981\u642c\u5185\u5b58\u6240\u4ee5\u6162\u3002Vector \u7528\u4e86 synchronized\uff0c\u6027\u80fd\u5dee\u4e00\u622a\u3002LinkedList \u7528\u53cc\u5411\u94fe\u8868\uff0c\u6309\u5e8f\u53f7\u8981\u904d\u5386\uff0c\u63d2\u5165\u53ea\u6539\u524d\u540e\u6307\u9488\uff0c\u63d2\u5165\u66f4\u5feb\u3002<\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">ArrayList \u548c LinkedList<\/h3>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>ArrayList \u57fa\u4e8e\u52a8\u6001\u6570\u7ec4\uff0cLinkedList \u57fa\u4e8e\u94fe\u8868\u3002<\/section>\n<\/li>\n<li>\n<section>\u968f\u673a\u8bbf\u95ee get \/ set\uff0cArrayList \u66f4\u597d\uff0cLinkedList \u8981\u79fb\u52a8\u6307\u9488\u3002<\/section>\n<\/li>\n<li>\n<section>\u65b0\u589e\u5220\u9664 add \/ remove\uff0cLinkedList \u901a\u5e38\u66f4\u5360\u4f18\uff0cArrayList \u8981\u642c\u6570\u636e\u3002<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">\u53ea\u63d2\u5220\u4e00\u6761\u65f6\uff0cArrayList \u6709\u65f6\u53cd\u800c\u66f4\u5feb\uff1b\u6279\u91cf\u968f\u673a\u63d2\u5220\u65f6 LinkedList \u4f1a\u660e\u663e\u9886\u5148\uff0c\u56e0\u4e3a ArrayList \u6bcf\u63d2\u4e00\u6761\u90fd\u8981\u79fb\u52a8\u63d2\u5165\u70b9\u4e4b\u540e\u7684\u6240\u6709\u6570\u636e\u3002<\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">HashMap \u4e0e TreeMap<\/h3>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>HashMap \u9760 hashCode \u5feb\u901f\u67e5\u627e\uff0c\u8fed\u4ee3\u987a\u5e8f\u4e0d\u56fa\u5b9a\uff1bTreeMap \u4fdd\u6301\u56fa\u5b9a\u987a\u5e8f\uff08\u81ea\u7136\u5e8f\u6216\u6bd4\u8f83\u5668\uff09\uff0c\u9700\u8981\u6709\u5e8f\u7ed3\u679c\u5c31\u7528\u5b83\u3002<\/section>\n<\/li>\n<li>\n<section>\u96c6\u5408\u6846\u67b6\u63d0\u4f9b\u4e24\u79cd\u5e38\u89c4 Map\uff1aHashMap \u548c TreeMap\uff08TreeMap \u5b9e\u73b0 SortedMap\uff09\u3002<\/section>\n<\/li>\n<li>\n<section>\u63d2\u5165\u3001\u5220\u9664\u3001\u5b9a\u4f4d\u5143\u7d20\uff0cHashMap \u6700\u597d\uff1b\u6309\u81ea\u7136\u5e8f\u6216\u81ea\u5b9a\u4e49\u987a\u5e8f\u904d\u5386\u952e\uff0c\u7528 TreeMap\u3002HashMap \u8981\u6c42\u952e\u7c7b\u6b63\u786e\u5b9e\u73b0 hashCode() \u548c equals()\u3002TreeMap \u6ca1\u6709\u8c03\u4f18\u9009\u9879\uff0c\u6811\u603b\u4fdd\u6301\u5e73\u8861\u3002<\/section>\n<\/li>\n<\/ul>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">Hashtable \u4e0e HashMap<\/h3>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u5386\u53f2\uff1aHashtable \u57fa\u4e8e\u65e7\u7684 Dictionary\uff1bHashMap \u662f Java 1.2 \u5f15\u8fdb\u7684 Map \u5b9e\u73b0\u3002<\/section>\n<\/li>\n<li>\n<section>\u540c\u6b65\uff1aHashtable \u7ebf\u7a0b\u5b89\u5168\uff1bHashMap \u4e0d\u662f\u3002<\/section>\n<\/li>\n<li>\n<section>\u7a7a\u503c\uff1a\u53ea\u6709 HashMap \u5141\u8bb8 null \u4f5c\u4e3a key \u6216 value\u3002<\/section>\n<\/li>\n<\/ul>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\">\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u4e00\u53e5\u8bdd\u603b\u7ed3\uff1aCollection \u7ba1\u5355\u5217\uff0cMap \u7ba1\u952e\u503c\uff1b\u9009\u5b9e\u73b0\u65f6\u5148\u95ee\uff1a\u8981\u4e0d\u8981\u540c\u6b65\u3001\u8981\u4e0d\u8981\u6709\u5e8f\u3001\u4e3b\u8981\u662f\u67e5\u8fd8\u662f\u63d2\u3002<\/strong><\/p>\n<\/blockquote>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u5bb9\u5668\u662f Java \u5b66\u4e60\u91cc\u5f88\u91cd\u7684\u4e00\u5757\u3002\u521a\u5f00\u59cb\u4f1a\u89c9\u5f97\u96be\uff0c\u7528\u719f\u4e86\u5c31\u987a\u3002\u5bb9\u5668\u7c7b\u4e3b\u8981\u7531\u4e24\u4e2a\u63a5\u53e3\u6d3e\u751f\uff1aCollection [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18],"tags":[177],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/359"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=359"}],"version-history":[{"count":3,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/359\/revisions"}],"predecessor-version":[{"id":655,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/359\/revisions\/655"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}