{"id":203432,"date":"2025-05-22T12:17:36","date_gmt":"2025-05-22T04:17:36","guid":{"rendered":"https:\/\/server.hk\/cnblog\/203432\/"},"modified":"2025-05-22T12:17:36","modified_gmt":"2025-05-22T04:17:36","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8java%e5%b0%86%e4%b8%80%e4%b8%aa%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","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/203432\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528Java\u5c06\u4e00\u4e2a\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\u4f7f\u7528Java\u5c06\u4e00\u4e2a\u6570\u7ec4\u6309\u7167\u7279\u5b9a\u5143\u7d20\u62c6\u5206\u4e3a\u591a\u4e2a\u65b0\u6570\u7ec4\uff1f<\/h1>\n<p><span style=\"color: #222222;, sans-serif;background-color: #FFFFFF\">\u5404\u4f4d\u5c0f\u4f19\u4f34\u4eec\uff0c\u5927\u5bb6\u597d\u5440\uff01\u770b\u770b\u4eca\u5929\u6211\u53c8\u7ed9\u5404\u4f4d\u5e26\u6765\u4e86\u4ec0\u4e48\u6587\u7ae0\uff1f\u672c\u6587\u6807\u9898<span style=\"color: #222222;, sans-serif;background-color: #FFFFFF\">\u662f<\/span><span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5982\u4f55\u4f7f\u7528Java\u5c06\u4e00\u4e2a\u6570\u7ec4\u6309\u7167\u7279\u5b9a\u5143\u7d20\u62c6\u5206\u4e3a\u591a\u4e2a\u65b0\u6570\u7ec4\uff1f\u300b<\/span>\uff0c\u5f88\u660e\u663e\u662f\u5173\u4e8e<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u7684\u6587\u7ae0\u54c8\u54c8\u54c8\uff0c\u5176\u4e2d\u5185\u5bb9\u4e3b\u8981\u4f1a\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\uff0c\u5982\u679c\u80fd\u5e2e\u5230\u4f60\uff0c\u89c9\u5f97\u5f88\u4e0d\u9519\u7684\u8bdd\uff0c\u6b22\u8fce\u5404\u4f4d\u591a\u591a\u70b9\u8bc4\u548c\u5206\u4eab\uff01<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241108\/1731037710672d8a0e5339e.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>java\u6570\u7ec4\u62c6\u5206<\/strong><\/p>\n<p><strong>\u95ee\u9898\uff1a<\/strong><\/p>\n<p>\u5982\u4f55\u5c06\u4e00\u4e2a\u6570\u7ec4\uff08\u4f8b\u5982\uff1a[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]))\u6309\u7167\u67d0\u4e2a\u7279\u5b9a\u5143\u7d20\uff08\u4f8b\u5982\uff1a85\uff09\u62c6\u5206\u4e3a\u591a\u4e2a\u65b0\u6570\u7ec4\uff1f<\/p>\n<p><strong>\u7b54\u6848\uff1a<\/strong><\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u65b9\u6cd5\u5c06\u6570\u7ec4\u62c6\u5206\u4e3a\u65b0\u6570\u7ec4\uff1a<\/p>\n<pre>public static void arrfun(int[] arr, int splitvalue) {\n    list&lt;list&lt;integer&gt;&gt; list = new arraylist&lt;&gt;();\n    list&lt;integer&gt; temp = new arraylist&lt;&gt;();\n    for (int i = 0; i &lt; arr.length; i++) {\n        if (arr[i] == splitvalue) {\n            if (!temp.isempty()) {\n                list.add(new arraylist&lt;&gt;(temp));\n                temp.clear();\n            }\n            temp.add(arr[i]);\n        } else {\n            temp.add(arr[i]);\n        }\n    }\n    list.add(temp);\n    system.out.println(\"\u62c6\u5206\u540e\u7684\u6570\u7ec4\uff1a\");\n    for (list&lt;integer&gt; item : list) {\n        system.out.println(arrays.tostring(item.toarray()));\n    }\n}<\/pre>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>int[] arr = {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};\narrfun(arr, 85);<\/pre>\n<p><strong>\u8f93\u51fa\uff1a<\/strong><\/p>\n<pre>\u62c6\u5206\u540e\u7684\u6570\u7ec4\uff1a\n[85, -86, 13, 2, 99, 99, 99, 99, 98, 98, 99, 99, 99, 99, 20]\n[85, -86, 13, 2, 99, 99, 99, 99, 99, 99, 99]\n[85, 12]\n[85, -86, 13, 2, 99]<\/pre>\n<p>\u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300a\u5982\u4f55\u4f7f\u7528Java\u5c06\u4e00\u4e2a\u6570\u7ec4\u6309\u7167\u7279\u5b9a\u5143\u7d20\u62c6\u5206\u4e3a\u591a\u4e2a\u65b0\u6570\u7ec4\uff1f\u300b\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u7ed9\u5927\u5bb6\u5206\u4eab\u66f4\u591a\u6587\u7ae0\u77e5\u8bc6\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528Java\u5c06\u4e00\u4e2a\u6570\u7ec4\u6309\u7167\u7279&#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-203432","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/203432","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=203432"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/203432\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=203432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=203432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=203432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}