{"id":203789,"date":"2025-05-22T14:18:08","date_gmt":"2025-05-22T06:18:08","guid":{"rendered":"https:\/\/server.hk\/cnblog\/203789\/"},"modified":"2025-05-22T14:18:08","modified_gmt":"2025-05-22T06:18:08","slug":"%e5%a6%82%e4%bd%95%e7%94%a8-java-%e4%bb%a3%e7%a0%81%e5%b0%86%e6%95%b0%e7%bb%84%e6%8c%89%e7%85%a7%e7%89%b9%e5%ae%9a%e5%85%83%e7%b4%a0%e6%8b%86%e5%88%86%e4%b8%ba%e5%a4%9a%e4%b8%aa%e6%96%b0%e6%95%b0","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/203789\/","title":{"rendered":"\u5982\u4f55\u7528 Java \u4ee3\u7801\u5c06\u6570\u7ec4\u6309\u7167\u7279\u5b9a\u5143\u7d20\u62c6\u5206\u4e3a\u591a\u4e2a\u65b0\u6570\u7ec4\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u5982\u4f55\u7528 Java \u4ee3\u7801\u5c06\u6570\u7ec4\u6309\u7167\u7279\u5b9a\u5143\u7d20\u62c6\u5206\u4e3a\u591a\u4e2a\u65b0\u6570\u7ec4\uff1f<\/h1>\n<p>\u5728\u6587\u7ae0\u5b9e\u6218\u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u9047\u5230\u4e00\u4e9b\u8fd9\u6837\u90a3\u6837\u7684\u95ee\u9898\uff0c\u7136\u540e\u8981\u5361\u597d\u534a\u5929\uff0c\u7b49\u95ee\u9898\u89e3\u51b3\u4e86\u624d\u53d1\u73b0\u539f\u6765\u4e00\u4e9b\u7ec6\u8282\u77e5\u8bc6\u70b9\u8fd8\u662f\u6ca1\u6709\u638c\u63e1\u597d\u3002\u4eca\u5929\u5c31\u6574\u7406\u5206\u4eab\u300a\u5982\u4f55\u7528 Java \u4ee3\u7801\u5c06\u6570\u7ec4\u6309\u7167\u7279\u5b9a\u5143\u7d20\u62c6\u5206\u4e3a\u591a\u4e2a\u65b0\u6570\u7ec4\uff1f\u300b\uff0c\u804a\u804a\uff0c\u5e0c\u671b\u53ef\u4ee5\u5e2e\u52a9\u5230\u6b63\u5728\u52aa\u529b\u8d5a\u94b1\u7684\u4f60\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241124\/17324278696742c05d5a84f.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u7528 java \u6839\u636e\u6307\u5b9a\u5143\u7d20\u62c6\u5206\u6570\u7ec4<\/strong><\/p>\n<p>\u5728 java \u4e2d\uff0c\u5982\u4f55\u5c06\u6570\u7ec4\u6309\u7167\u7279\u5b9a\u5143\u7d20\uff08\u4f8b\u5982 85\uff09\u62c6\u5206\u4e3a\u591a\u4e2a\u65b0\u6570\u7ec4\uff1f<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528 java \u4ee3\u7801\u5b9e\u73b0\u6b64\u529f\u80fd\u7684\u793a\u4f8b\uff1a<\/p>\n<pre>import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\n\npublic class ArraySplitter {\n\n    public static void splitArrayByElement(int[] arr, int delimiter) {\n        List&lt;List&lt;Integer&gt;&gt; resultList = new ArrayList&lt;&gt;();\n        List&lt;Integer&gt; tempList = new ArrayList&lt;&gt;();\n\n        for (int elem : arr) {\n            if (elem == delimiter) {\n                if (!tempList.isEmpty()) {\n                    resultList.add(new ArrayList&lt;&gt;(tempList));\n                    tempList.clear();\n                }\n                tempList.add(elem);\n            } else {\n                tempList.add(elem);\n            }\n        }\n\n        if (!tempList.isEmpty()) {\n            resultList.add(tempList);\n        }\n\n        System.out.println(\"\u62c6\u5206\u540e\u7684\u5b50\u6570\u7ec4\uff1a\");\n        for (List&lt;Integer&gt; subarray : resultList) {\n            System.out.println(Arrays.toString(subarray.toArray()));\n        }\n    }\n\n    public static void main(String[] args) {\n        int[] inputArray = {85, -86, 13, 2, 99, 99, 99, 99, 98, 98, 99, 99, 99, 99, 20, 85, -86, 13, 2, 99, 99, 99, 99, 99, 99, 99, 85, 12, 85, -86, 13, 2, 99};\n\n        splitArrayByElement(inputArray, 85);\n    }\n}<\/pre>\n<p>\u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8e\u6587\u7ae0\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u7528 Java \u4ee3\u7801\u5c06\u6570\u7ec4\u6309\u7167&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-203789","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/203789","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=203789"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/203789\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=203789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=203789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=203789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}