{"id":70530,"date":"2026-02-02T01:25:45","date_gmt":"2026-02-01T17:25:45","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/70530.html"},"modified":"2026-02-02T01:25:45","modified_gmt":"2026-02-01T17:25:45","slug":"java%e5%85%b3%e4%ba%8e%e9%9b%86%e5%90%88%e7%b1%bb","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/70530.html","title":{"rendered":"java\u5173\u4e8e\u96c6\u5408\u7c7b"},"content":{"rendered":"<h2>\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"632\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260201172544-697f8c9860bb1.png\" width=\"1114\" \/><\/h2>\n<h2>\u00a0\u4e00\u3001\u5355\u5217\u96c6\u5408<\/h2>\n<h3>1. Collection<\/h3>\n<h4>\u76f8\u5173\u65b9\u6cd5<\/h4>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\">\n<tr>\u65b9\u6cd5\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>boolean add(E e)<\/td>\n<td>\u628a\u7ed9\u5b9a\u7684\u5bf9\u8c61\u6dfb\u52a0\u5230\u5f53\u524d\u96c6\u5408\u4e2d<\/td>\n<\/tr>\n<tr>\n<td>void clear()<\/td>\n<td>\u6e05\u7a7a\u96c6\u5408\u4e2d\u6240\u6709\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>boolean remove(E e)<\/td>\n<td>\u628a\u7ed9\u5b9a\u7684\u5bf9\u8c61\u5728\u5f53\u524d\u96c6\u5408\u4e2d\u5220\u9664<\/td>\n<\/tr>\n<tr>\n<td>boolean contains(Object obj)<\/td>\n<td>\u5224\u65ad\u5f53\u524d\u96c6\u5408\u4e2d\u662f\u5426\u5305\u542b\u7ed9\u5b9a\u7684\u5bf9\u8c61<\/td>\n<\/tr>\n<tr>\n<td>boolean isEmpty()<\/td>\n<td>\u5224\u65ad\u5f53\u524d\u96c6\u5408\u662f\u5426\u4e3a\u7a7a<\/td>\n<\/tr>\n<tr>\n<td>int size()<\/td>\n<td>\u8fd4\u56de\u96c6\u5408\u4e2d\u5143\u7d20\u7684\u4e2a\u6570 \/ \u96c6\u5408\u7684\u957f\u5ea6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>2. List<\/h3>\n<h4>\u76f8\u5173\u65b9\u6cd5<\/h4>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\">\n<tr>\u65b9\u6cd5\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>void add(int index,E element)<\/td>\n<td>\u5728\u6b64\u96c6\u5408\u4e2d\u7684\u6307\u5b9a\u4f4d\u7f6e\u63d2\u5165\u6307\u5b9a\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>E remove(int index)<\/td>\n<td>\u5220\u9664\u6307\u5b9a\u7d22\u5f15\u5904\u7684\u5143\u7d20&#xff0c;\u8fd4\u56de\u88ab\u5220\u9664\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>E set(int index,E element)<\/td>\n<td>\u4fee\u6539\u6307\u5b9a\u7d22\u5f15\u5904\u7684\u5143\u7d20&#xff0c;\u8fd4\u56de\u88ab\u4fee\u6539\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>E get(int index)<\/td>\n<td>\u8fd4\u56de\u6307\u5b9a\u7d22\u5f15\u5904\u7684\u5143\u7d20<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>3. ArrayList<\/h3>\n<h4>\u76f8\u5173\u65b9\u6cd5<\/h4>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\">\n<tr>\u65b9\u6cd5\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>boolean add(E e)<\/td>\n<td>\u6dfb\u52a0\u5143\u7d20&#xff0c;\u8fd4\u56de\u503c\u8868\u793a\u662f\u5426\u6dfb\u52a0\u6210\u529f<\/td>\n<\/tr>\n<tr>\n<td>boolean remove(E e)<\/td>\n<td>\u5220\u9664\u6307\u5b9a\u5143\u7d20&#xff0c;\u8fd4\u56de\u503c\u8868\u793a\u662f\u5426\u5220\u9664\u6210\u529f<\/td>\n<\/tr>\n<tr>\n<td>E remove(int index)<\/td>\n<td>\u5220\u9664\u6307\u5b9a\u7d22\u5f15\u7684\u5143\u7d20&#xff0c;\u8fd4\u56de\u88ab\u5220\u9664\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>E set(int index,E e)<\/td>\n<td>\u4fee\u6539\u6307\u5b9a\u7d22\u5f15\u4e0b\u7684\u5143\u7d20&#xff0c;\u8fd4\u56de\u539f\u6765\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>E get(int index)<\/td>\n<td>\u83b7\u53d6\u6307\u5b9a\u7d22\u5f15\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>int size()<\/td>\n<td>\u96c6\u5408\u4e2d\u5143\u7d20\u7684\u6570\u91cf<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u904d\u5386\u65b9\u5f0f<\/h4>\n<h5>\u8fed\u4ee3\u5668<\/h5>\n<p>public static void main(String[] args) {<br \/>\n        ArrayList&lt;String&gt; list &#061; new ArrayList&lt;&gt;();<br \/>\n        list.add(&#034;a&#034;);<br \/>\n        list.add(&#034;b&#034;);<br \/>\n        list.add(&#034;c&#034;);<br \/>\n        Iterator&lt;String&gt; it &#061; list.iterator();<br \/>\n        while(it.hasNext()) {<br \/>\n            String s &#061; it.next();<br \/>\n            System.out.println(s);<br \/>\n        }<br \/>\n    }<\/p>\n<h5>\u5217\u8868\u8fed\u4ee3\u5668<\/h5>\n<p>public static void main(String[] args) {<br \/>\n        ArrayList&lt;String&gt; list &#061; new ArrayList&lt;&gt;();<br \/>\n        list.add(&#034;a&#034;);<br \/>\n        list.add(&#034;b&#034;);<br \/>\n        list.add(&#034;c&#034;);<br \/>\n        ListIterator&lt;String&gt; listIterator &#061; list.listIterator();<br \/>\n        while(listIterator.hasNext()) {<br \/>\n            System.out.println(listIterator.next());<br \/>\n        }<br \/>\n    }<\/p>\n<h5>\u589e\u5f3afor<\/h5>\n<p>public static void main(String[] args) {<br \/>\n        ArrayList&lt;String&gt; list &#061; new ArrayList&lt;&gt;();<br \/>\n        list.add(&#034;a&#034;);<br \/>\n        list.add(&#034;b&#034;);<br \/>\n        list.add(&#034;c&#034;);<br \/>\n        for(String s : list) {<br \/>\n            System.out.println(s);<br \/>\n        }<br \/>\n    }<\/p>\n<h5>lambda\u8868\u8fbe\u5f0f\u904d\u5386<\/h5>\n<p>public static void main(String[] args) {<br \/>\n        ArrayList&lt;String&gt; list &#061; new ArrayList&lt;&gt;();<br \/>\n        list.add(&#034;a&#034;);<br \/>\n        list.add(&#034;b&#034;);<br \/>\n        list.add(&#034;c&#034;);<br \/>\n        list.forEach(s -&gt; System.out.println(s));<br \/>\n    }<\/p>\n<h5>\u666e\u901afor<\/h5>\n<p>public static void main(String[] args) {<br \/>\n        ArrayList&lt;String&gt; list &#061; new ArrayList&lt;&gt;();<br \/>\n        list.add(&#034;a&#034;);<br \/>\n        list.add(&#034;b&#034;);<br \/>\n        list.add(&#034;c&#034;);<br \/>\n        for (int i &#061; 0; i &lt; list.size(); i&#043;&#043;) {<br \/>\n            System.out.println(list.get(i));<br \/>\n        }<br \/>\n    }<\/p>\n<h3>4. LinkedList<\/h3>\n<h4>\u76f8\u5173\u65b9\u6cd5<\/h4>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\">\n<tr>\u65b9\u6cd5\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>void addFirst(E e)<\/td>\n<td>\u5728\u8be5\u5217\u8868\u5f00\u5934\u63d2\u5165\u6307\u5b9a\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>void addLast(E e)<\/td>\n<td>\u5c06\u6307\u5b9a\u7684\u5143\u7d20\u8ffd\u52a0\u5230\u6b64\u5217\u8868\u7684\u672b\u5c3e<\/td>\n<\/tr>\n<tr>\n<td>E getFirst()<\/td>\n<td>\u8fd4\u56de\u6b64\u5217\u8868\u4e2d\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>E getLast()<\/td>\n<td>\u8fd4\u56de\u6b64\u5217\u8868\u4e2d\u7684\u6700\u540e\u4e00\u4e2a\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>E removeFirst()<\/td>\n<td>\u4ece\u6b64\u5217\u8868\u4e2d\u5220\u9664\u5e76\u8fd4\u56de\u7b2c\u4e00\u4e2a\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>E removeLast()<\/td>\n<td>\u4ece\u6b64\u5217\u8868\u4e2d\u5220\u9664\u5e76\u8fd4\u56de\u6700\u540e\u4e00\u4e2a\u5143\u7d20<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>5. Set<\/h3>\n<h4>\u76f8\u5173\u65b9\u6cd5<\/h4>\n<p>\u7ee7\u627f\u4e8eCollection<\/p>\n<h3>6. HashSet<\/h3>\n<h4>\u76f8\u5173\u65b9\u6cd5<\/h4>\n<p>\u7ee7\u627f\u4e8eSet<\/p>\n<p>\u7279\u70b9&#xff1a;\u65e0\u5e8f\u3001\u4e0d\u91cd\u590d\u3001\u65e0\u7d22\u5f15<\/p>\n<h3>7. LinkedHashSet<\/h3>\n<h4>\u76f8\u5173\u65b9\u6cd5<\/h4>\n<p>\u7ee7\u627f\u4e8eSet<\/p>\n<p>\u7279\u70b9&#xff1a;\u6709\u5e8f\u3001\u4e0d\u91cd\u590d\u3001\u65e0\u7d22\u5f15<\/p>\n<h3>8. TreeSet<\/h3>\n<h4>\u76f8\u5173\u65b9\u6cd5<\/h4>\n<table>\n<tr>\u65b9\u6cd5\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>E first()<\/td>\n<td>\u83b7\u53d6\u6700\u5c0f\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>E last()<\/td>\n<td>\u83b7\u53d6\u6700\u5927\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>E lower(E e)<\/td>\n<td>\u83b7\u53d6 \u5c0f\u4e8e e \u7684\u6700\u5927\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>E higher(E e)<\/td>\n<td>\u83b7\u53d6 \u5927\u4e8e e \u7684\u6700\u5c0f\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>E floor(E e)<\/td>\n<td>\u83b7\u53d6\u00a0\u5c0f\u4e8e\u7b49\u4e8ee \u7684\u6700\u5927\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>E ceiling(E e)<\/td>\n<td>\u83b7\u53d6\u00a0\u5927\u4e8e\u7b49\u4e8ee \u7684\u6700\u5c0f\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>SortedSet&lt;E&gt; subSet(E from, E to)<\/td>\n<td>\u83b7\u53d6 [from, to) \u533a\u95f4\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>SortedSet&lt;E&gt; headSet(E to)<\/td>\n<td>\u83b7\u53d6\u5c0f\u4e8e to \u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>SortedSet&lt;E&gt; tailSet(E from)<\/td>\n<td>\u83b7\u53d6\u5927\u4e8e\u7b49\u4e8e from \u7684\u5143\u7d20<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7279\u70b9&#xff1a;\u53ef\u6392\u5e8f\u3001\u4e0d\u91cd\u590d\u3001\u65e0\u7d22\u5f15<\/p>\n<h4>\u6392\u5e8f\u65b9\u5f0f<\/h4>\n<h5>\u65b9\u5f0f\u4e00<\/h5>\n<p>\u5728javaBean\u4e2d\u5b9e\u73b0Comparable\u63a5\u53e3\u6307\u5b9a\u6392\u5e8f\u89c4\u5219<\/p>\n<h5>\u65b9\u5f0f\u4e8c<\/h5>\n<p>\u521b\u5efaTreeSet\u5bf9\u8c61\u65f6&#xff0c;\u4f20\u9012\u6bd4\u8f83\u5668Comparable\u6307\u5b9a\u89c4\u5219<\/p>\n<h3>\u5355\u5217\u96c6\u5408\u4f7f\u7528\u573a\u666f<\/h3>\n<p>1. \u5982\u679c\u60f3\u8981\u96c6\u5408\u4e2d\u7684\u5143\u7d20\u53ef\u91cd\u590d<\/p>\n<p>\u7528ArrayList\u96c6\u5408&#xff0c;\u57fa\u4e8e\u6570\u7ec4\u7684\u3002&#xff08;\u7528\u7684\u6700\u591a&#xff09;<br \/>\n2. \u5982\u679c\u60f3\u8981\u96c6\u5408\u4e2d\u7684\u5143\u7d20\u53ef\u91cd\u590d&#xff0c;\u800c\u4e14\u5f53\u524d\u7684\u589e\u5220\u64cd\u4f5c\u660e\u663e\u591a\u4e8e\u67e5\u8be2<\/p>\n<p>\u7528LinkedList\u96c6\u5408&#xff0c;\u57fa\u4e8e\u94fe\u8868\u7684\u3002<br \/>\n3. \u5982\u679c\u60f3\u5bf9\u96c6\u5408\u4e2d\u7684\u5143\u7d20\u53bb\u91cd<\/p>\n<p>\u7528HashSet\u96c6\u5408&#xff0c;\u57fa\u4e8e\u54c8\u5e0c\u8868\u7684\u3002&#xff08;\u7528\u7684\u6700\u591a&#xff09;<br \/>\n4. \u5982\u679c\u60f3\u5bf9\u96c6\u5408\u4e2d\u7684\u5143\u7d20\u53bb\u91cd&#xff0c;\u800c\u4e14\u4fdd\u8bc1\u5b58\u53d6\u987a\u5e8f<\/p>\n<p>\u7528LinkedHashSet\u96c6\u5408&#xff0c;\u57fa\u4e8e\u54c8\u5e0c\u8868\u548c\u53cc\u94fe\u8868&#xff0c;\u6548\u7387\u4f4e\u4e8eHashSet\u3002<br \/>\n5. \u5982\u679c\u60f3\u5bf9\u96c6\u5408\u4e2d\u7684\u5143\u7d20\u8fdb\u884c\u6392\u5e8f<\/p>\n<p>\u7528TreeSet\u96c6\u5408&#xff0c;\u57fa\u4e8e\u7ea2\u9ed1\u6811\u3002\u540e\u7eed\u4e5f\u53ef\u4ee5\u7528List\u96c6\u5408\u5b9e\u73b0\u6392\u5e8f<\/p>\n<h2>\u4e8c\u3001\u53cc\u5217\u96c6\u5408<\/h2>\n<h3 style=\"background-color:transparent\">1. Map<\/h3>\n<h4>\u76f8\u5173\u65b9\u6cd5<\/h4>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\" style=\"width:800px\">\n<tr>\u65b9\u6cd5\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td style=\"width:247px\">V put(K key,V value)<\/td>\n<td style=\"width:452px\">\u6dfb\u52a0\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td style=\"width:247px\">V remove(Object key)<\/td>\n<td style=\"width:452px\">\u6839\u636e\u952e\u5220\u9664\u952e\u503c\u5bf9\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td style=\"width:247px\">void clear()<\/td>\n<td style=\"width:452px\">\u79fb\u9664\u6240\u6709\u7684\u952e\u503c\u5bf9\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td style=\"width:247px\">boolean containsKey(Object key)<\/td>\n<td style=\"width:452px\">\u5224\u65ad\u96c6\u5408\u662f\u5426\u5305\u542b\u6307\u5b9a\u7684\u952e<\/td>\n<\/tr>\n<tr>\n<td style=\"width:247px\">boolean containsValue(Object value)<\/td>\n<td style=\"width:452px\">\u5224\u65ad\u96c6\u5408\u662f\u5426\u5305\u542b\u6307\u5b9a\u7684\u503c<\/td>\n<\/tr>\n<tr>\n<td style=\"width:247px\">boolean isEmpty()<\/td>\n<td style=\"width:452px\">\u5224\u65ad\u96c6\u5408\u662f\u5426\u4e3a\u7a7a<\/td>\n<\/tr>\n<tr>\n<td style=\"width:247px\">int size()<\/td>\n<td style=\"width:452px\">\u96c6\u5408\u7684\u957f\u5ea6&#xff0c;\u4e5f\u5c31\u662f\u96c6\u5408\u4e2d\u952e\u503c\u5bf9\u7684\u4e2a\u6570<\/td>\n<\/tr>\n<tr>\n<td style=\"width:247px\">V getOrDefault(Object key, V defaultValue)<\/td>\n<td style=\"width:452px\">\u4ece Map \u4e2d\u53d6 key \u5bf9\u5e94\u7684\u503c&#xff0c;\u5982\u679c key \u4e0d\u5b58\u5728&#xff0c;\u8fd4\u56de\u9ed8\u8ba4\u503c\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>2. HashMap<\/h3>\n<h4>\u76f8\u5173\u65b9\u6cd5<\/h4>\n<p>\u7ee7\u627f\u4e8eMap<\/p>\n<h4>\u904d\u5386\u65b9\u5f0f<\/h4>\n<h5>\u952e\u627e\u503c<\/h5>\n<p>public static void main(String[] args) {<br \/>\n        HashMap&lt;String,String&gt; map &#061; new HashMap&lt;&gt;();<br \/>\n        map.put(&#034;A&#034;,&#034;65&#034;);<br \/>\n        map.put(&#034;B&#034;,&#034;66&#034;);<br \/>\n        map.put(&#034;C&#034;,&#034;67&#034;);<br \/>\n        Set&lt;String&gt; keys &#061; map.keySet();<br \/>\n        for (String key : keys) {<br \/>\n            String value &#061; map.get(key);<br \/>\n            System.out.println(key &#043; &#034; &#061; &#034; &#043; value);<br \/>\n        }<br \/>\n    }<\/p>\n<h5>\u952e\u503c\u5bf9<\/h5>\n<p>public static void main(String[] args) {<br \/>\n        HashMap&lt;String, String&gt; map &#061; new HashMap&lt;&gt;();<br \/>\n        map.put(&#034;A&#034;, &#034;65&#034;);<br \/>\n        map.put(&#034;B&#034;, &#034;66&#034;);<br \/>\n        map.put(&#034;C&#034;, &#034;67&#034;);<br \/>\n        Set&lt;Map.Entry&lt;String, String&gt;&gt; entries &#061; map.entrySet();<br \/>\n        for (Map.Entry&lt;String, String&gt; entry : entries) {<br \/>\n            String key &#061; entry.getKey();<br \/>\n            String value &#061; entry.getValue();<br \/>\n            System.out.println(key &#043; &#034;&#061;&#034; &#043; value);<br \/>\n        }<br \/>\n    }<\/p>\n<h5>Lambda\u8868\u8fbe\u5f0f<\/h5>\n<p>public static void main(String[] args) {<br \/>\n        HashMap&lt;String,String&gt; map &#061; new HashMap&lt;&gt;();<br \/>\n        map.put(&#034;A&#034;,&#034;65&#034;);<br \/>\n        map.put(&#034;B&#034;,&#034;66&#034;);<br \/>\n        map.put(&#034;C&#034;,&#034;67&#034;);<br \/>\n        \/\/ \u5b8c\u6574\u7248<br \/>\n        map.forEach(new BiConsumer&lt;String, String&gt;() {<br \/>\n            &#064;Override<br \/>\n            public void accept(String key, String value) {<br \/>\n                System.out.println(key &#043; &#034;&#061;&#034; &#043; value);<br \/>\n            }<br \/>\n        });<\/p>\n<p>        System.out.println(&#034;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#034;);<br \/>\n        \/\/ \u7b80\u5199\u7248<br \/>\n        map.forEach((String key, String value)-&gt;{<br \/>\n            System.out.println(key &#043; &#034;&#061;&#034; &#043; value);<br \/>\n        });<br \/>\n    }<\/p>\n<h3>3. LinkedHashMap<\/h3>\n<h4>\u76f8\u5173\u65b9\u6cd5<\/h4>\n<p>\u7ee7\u627f\u4e8eHashMap<\/p>\n<h3>4. TreeMap<\/h3>\n<h4>\u76f8\u5173\u65b9\u6cd5<\/h4>\n<table>\n<tr>\u65b9\u6cd5\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>K firstKey()<\/td>\n<td>\u8fd4\u56de\u6700\u5c0f key<\/td>\n<\/tr>\n<tr>\n<td>K lastKey()<\/td>\n<td>\u8fd4\u56de\u6700\u5927 key<\/td>\n<\/tr>\n<tr>\n<td>K lowerKey(K key)<\/td>\n<td>\u8fd4\u56de\u5c0f\u4e8e key \u7684\u6700\u5927 key<\/td>\n<\/tr>\n<tr>\n<td>K higherKey(K key)<\/td>\n<td>\u8fd4\u56de\u5927\u4e8e key \u7684\u6700\u5c0f key<\/td>\n<\/tr>\n<tr>\n<td>K floorKey(K key)<\/td>\n<td>\u8fd4\u56de \u2264 key \u7684\u6700\u5927 key<\/td>\n<\/tr>\n<tr>\n<td>K ceilingKey(K key)<\/td>\n<td>\u8fd4\u56de \u2265 key \u7684\u6700\u5c0f key<\/td>\n<\/tr>\n<tr>\n<td>SortedMap&lt;K,V&gt; subMap(K fromKey, K toKey)<\/td>\n<td>\u8fd4\u56de\u5b50 Map<\/td>\n<\/tr>\n<tr>\n<td>SortedMap&lt;K,V&gt; headMap(K toKey)<\/td>\n<td>\u8fd4\u56de\u5b50 Map<\/td>\n<\/tr>\n<tr>\n<td>SortedMap&lt;K,V&gt; tailMap(K fromKey)<\/td>\n<td>\u8fd4\u56de\u5b50 Map<\/td>\n<\/tr>\n<tr>\n<td>Comparator&lt;? super K&gt; comparator()<\/td>\n<td>\u8fd4\u56de\u6bd4\u8f83\u5668&#xff08;null &#061; \u81ea\u7136\u6392\u5e8f&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u6392\u5e8f\u89c4\u5219<\/h4>\n<h5>\u65b9\u5f0f\u4e00<\/h5>\n<p>\u5728javaBean\u4e2d\u5b9e\u73b0Comparable\u63a5\u53e3\u6307\u5b9a\u6392\u5e8f\u89c4\u5219<\/p>\n<h5>\u65b9\u5f0f\u4e8c<\/h5>\n<p>\u521b\u5efaTreeSet\u5bf9\u8c61\u65f6&#xff0c;\u4f20\u9012\u6bd4\u8f83\u5668Comparable\u6307\u5b9a\u89c4\u5219<\/p>\n<h2>\u4e09\u3001Collections\u5de5\u5177\u7c7b<\/h2>\n<h3>\u76f8\u5173\u65b9\u6cd5<\/h3>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\">\n<tr>\u65b9\u6cd5\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>static &lt;T&gt; boolean addAll(Collection&lt;T&gt; c, T&#8230; elements)<\/td>\n<td>\u6279\u91cf\u6dfb\u52a0\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>static void shuffle(List&lt;?&gt; list)<\/td>\n<td>\u6253\u4e71 List \u96c6\u5408\u5143\u7d20\u7684\u987a\u5e8f<\/td>\n<\/tr>\n<tr>\n<td>static &lt;T&gt; void sort(List&lt;T&gt; list)<\/td>\n<td>\u6392\u5e8f<\/td>\n<\/tr>\n<tr>\n<td>static &lt;T&gt; void sort(List&lt;T&gt; list, Comparator&lt;T&gt; c)<\/td>\n<td>\u6839\u636e\u6307\u5b9a\u7684\u89c4\u5219\u8fdb\u884c\u6392\u5e8f<\/td>\n<\/tr>\n<tr>\n<td>static &lt;T&gt; int binarySearch (List&lt;T&gt; list, T key)<\/td>\n<td>\u4ee5\u4e8c\u5206\u67e5\u627e\u6cd5\u67e5\u627e\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>static &lt;T&gt; void copy(List&lt;T&gt; dest, List&lt;T&gt; src)<\/td>\n<td>\u62f7\u8d1d\u96c6\u5408\u4e2d\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>static &lt;T&gt; int fill (List&lt;T&gt; list, T obj)<\/td>\n<td>\u4f7f\u7528\u6307\u5b9a\u7684\u5143\u7d20\u586b\u5145\u96c6\u5408<\/td>\n<\/tr>\n<tr>\n<td>static &lt;T&gt; void max\/min(Collection&lt;T&gt; coll)<\/td>\n<td>\u6839\u636e\u9ed8\u8ba4\u7684\u81ea\u7136\u6392\u5e8f\u83b7\u53d6\u6700\u5927 \u6216\u5c0f\u503c<\/td>\n<\/tr>\n<tr>\n<td>static &lt;T&gt; void swap(List&lt;?&gt; list, int i, int j)<\/td>\n<td>\u4ea4\u6362\u96c6\u5408\u4e2d\u6307\u5b9a\u4f4d\u7f6e\u7684\u5143\u7d20<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u56db\u3001\u4e0d\u53ef\u53d8\u96c6\u5408<\/h2>\n<h3>\u76f8\u5173\u65b9\u6cd5<\/h3>\n<table>\n<tr>\u65b9\u6cd5\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td style=\"width:476px\">static &lt;E&gt; List&lt;E&gt; of(E&#8230; elements)<\/td>\n<td style=\"width:213px\">\u521b\u5efa\u4e00\u4e2a\u4e0d\u53ef\u53d8\u7684 List<\/td>\n<\/tr>\n<tr>\n<td style=\"width:476px\">static &lt;E&gt; Set&lt;E&gt; of(E&#8230; elements)<\/td>\n<td style=\"width:213px\">\u521b\u5efa\u4e00\u4e2a\u4e0d\u53ef\u53d8\u7684 Set&#xff08;\u65e0\u91cd\u590d\u5143\u7d20&#xff09;<\/td>\n<\/tr>\n<tr>\n<td style=\"width:476px\">static &lt;K,V&gt; Map&lt;K,V&gt; of(K k1, V v1, K k2, V v2, &#8230;)<\/td>\n<td style=\"width:213px\">\u521b\u5efa\u4e00\u4e2a\u4e0d\u53ef\u53d8 Map<\/td>\n<\/tr>\n<tr>\n<td style=\"width:476px\">static &lt;E&gt; List&lt;E&gt; copyOf(Collection&lt;? extends E&gt; coll)<\/td>\n<td style=\"width:213px\">\u6839\u636e\u5df2\u6709\u96c6\u5408\u521b\u5efa\u4e0d\u53ef\u53d8 List<\/td>\n<\/tr>\n<tr>\n<td style=\"width:476px\">static &lt;E&gt; Set&lt;E&gt; copyOf(Collection&lt;? extends E&gt; coll)<\/td>\n<td style=\"width:213px\">\u6839\u636e\u5df2\u6709\u96c6\u5408\u521b\u5efa\u4e0d\u53ef\u53d8 Set<\/td>\n<\/tr>\n<tr>\n<td style=\"width:476px\">static &lt;K,V&gt; Map&lt;K,V&gt; copyOf(Map&lt;? extends K, ? extends V&gt; map)<\/td>\n<td style=\"width:213px\">\u6839\u636e\u5df2\u6709 Map \u521b\u5efa\u4e0d\u53ef\u53d8 Map<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u5355\u5217\u96c6\u54081. Collection\u76f8\u5173\u65b9\u6cd5\u65b9\u6cd5\u8bf4\u660eboolean add(E e)\u628a\u7ed9\u5b9a\u7684\u5bf9\u8c61\u6dfb\u52a0\u5230\u5f53\u524d\u96c6\u5408\u4e2dvoid clear()\u6e05\u7a7a\u96c6\u5408\u4e2d\u6240\u6709\u7684\u5143\u7d20boolean remove(E e)\u628a\u7ed9\u5b9a\u7684\u5bf9\u8c61\u5728\u5f53\u524d\u96c6\u5408\u4e2d\u5220\u9664boolean contains(Object obj)\u5224\u65ad\u5f53\u524d\u96c6\u5408\u4e2d\u662f\u5426\u5305\u542b\u7ed9\u5b9a\u7684\u5bf9\u8c61boolean isEmpty()\u5224\u65ad\u5f53\u524d\u96c6\u5408\u662f\u5426\u4e3a\u7a7aint size()\u8fd4\u56de\u96c6\u5408\u4e2d\u5143\u7d20\u7684\u4e2a\u6570 \/ \u96c6\u5408\u7684\u957f\u5ea62. List\u76f8\u5173\u65b9\u6cd5\u65b9\u6cd5\u8bf4\u660evoid add(int i<\/p>\n","protected":false},"author":2,"featured_media":70529,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[99],"topic":[],"class_list":["post-70530","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>java\u5173\u4e8e\u96c6\u5408\u7c7b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/70530.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"java\u5173\u4e8e\u96c6\u5408\u7c7b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001\u5355\u5217\u96c6\u54081. Collection\u76f8\u5173\u65b9\u6cd5\u65b9\u6cd5\u8bf4\u660eboolean add(E e)\u628a\u7ed9\u5b9a\u7684\u5bf9\u8c61\u6dfb\u52a0\u5230\u5f53\u524d\u96c6\u5408\u4e2dvoid clear()\u6e05\u7a7a\u96c6\u5408\u4e2d\u6240\u6709\u7684\u5143\u7d20boolean remove(E e)\u628a\u7ed9\u5b9a\u7684\u5bf9\u8c61\u5728\u5f53\u524d\u96c6\u5408\u4e2d\u5220\u9664boolean contains(Object obj)\u5224\u65ad\u5f53\u524d\u96c6\u5408\u4e2d\u662f\u5426\u5305\u542b\u7ed9\u5b9a\u7684\u5bf9\u8c61boolean isEmpty()\u5224\u65ad\u5f53\u524d\u96c6\u5408\u662f\u5426\u4e3a\u7a7aint size()\u8fd4\u56de\u96c6\u5408\u4e2d\u5143\u7d20\u7684\u4e2a\u6570 \/ \u96c6\u5408\u7684\u957f\u5ea62. List\u76f8\u5173\u65b9\u6cd5\u65b9\u6cd5\u8bf4\u660evoid add(int i\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/70530.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-01T17:25:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260201172544-697f8c9860bb1.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/70530.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/70530.html\",\"name\":\"java\u5173\u4e8e\u96c6\u5408\u7c7b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-01T17:25:45+00:00\",\"dateModified\":\"2026-02-01T17:25:45+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/70530.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/70530.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/70530.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"java\u5173\u4e8e\u96c6\u5408\u7c7b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"java\u5173\u4e8e\u96c6\u5408\u7c7b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/70530.html","og_locale":"zh_CN","og_type":"article","og_title":"java\u5173\u4e8e\u96c6\u5408\u7c7b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001\u5355\u5217\u96c6\u54081. Collection\u76f8\u5173\u65b9\u6cd5\u65b9\u6cd5\u8bf4\u660eboolean add(E e)\u628a\u7ed9\u5b9a\u7684\u5bf9\u8c61\u6dfb\u52a0\u5230\u5f53\u524d\u96c6\u5408\u4e2dvoid clear()\u6e05\u7a7a\u96c6\u5408\u4e2d\u6240\u6709\u7684\u5143\u7d20boolean remove(E e)\u628a\u7ed9\u5b9a\u7684\u5bf9\u8c61\u5728\u5f53\u524d\u96c6\u5408\u4e2d\u5220\u9664boolean contains(Object obj)\u5224\u65ad\u5f53\u524d\u96c6\u5408\u4e2d\u662f\u5426\u5305\u542b\u7ed9\u5b9a\u7684\u5bf9\u8c61boolean isEmpty()\u5224\u65ad\u5f53\u524d\u96c6\u5408\u662f\u5426\u4e3a\u7a7aint size()\u8fd4\u56de\u96c6\u5408\u4e2d\u5143\u7d20\u7684\u4e2a\u6570 \/ \u96c6\u5408\u7684\u957f\u5ea62. List\u76f8\u5173\u65b9\u6cd5\u65b9\u6cd5\u8bf4\u660evoid add(int i","og_url":"https:\/\/www.wsisp.com\/helps\/70530.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-01T17:25:45+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260201172544-697f8c9860bb1.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/70530.html","url":"https:\/\/www.wsisp.com\/helps\/70530.html","name":"java\u5173\u4e8e\u96c6\u5408\u7c7b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-01T17:25:45+00:00","dateModified":"2026-02-01T17:25:45+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/70530.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/70530.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/70530.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"java\u5173\u4e8e\u96c6\u5408\u7c7b"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/70530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=70530"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/70530\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/70529"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=70530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=70530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=70530"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=70530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}