{"id":39109,"date":"2024-11-26T17:18:59","date_gmt":"2024-11-26T09:18:59","guid":{"rendered":"https:\/\/fwq.ai\/blog\/39109\/"},"modified":"2024-11-26T17:18:59","modified_gmt":"2024-11-26T09:18:59","slug":"java%e4%b8%ad%e6%80%8e%e4%b9%88%e6%9b%b4%e6%94%b9%e6%95%b0%e7%bb%84%e9%95%bf%e5%ba%a6","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/39109\/","title":{"rendered":"java\u4e2d\u600e\u4e48\u66f4\u6539\u6570\u7ec4\u957f\u5ea6"},"content":{"rendered":"<blockquote><p>\n  \u5728 java \u4e2d\uff0c\u6570\u7ec4\u957f\u5ea6\u4e0d\u53ef\u53d8\u3002\u8981\u66f4\u6539\u6570\u7ec4\u957f\u5ea6\uff0c\u9700\uff1a\u521b\u5efa\u957f\u5ea6\u4e3a\u6240\u9700\u5927\u5c0f\u7684\u65b0\u6570\u7ec4\u3002\u590d\u5236\u65e7\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u5230\u65b0\u6570\u7ec4\u4e2d\u3002\u5c06\u6570\u7ec4\u53d8\u91cf\u6307\u5411\u65b0\u6570\u7ec4\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/16\/2024111604091961775.jpg\" class=\"aligncenter\" title=\"java\u4e2d\u600e\u4e48\u66f4\u6539\u6570\u7ec4\u957f\u5ea6\u63d2\u56fe\" alt=\"java\u4e2d\u600e\u4e48\u66f4\u6539\u6570\u7ec4\u957f\u5ea6\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 Java \u4e2d\u66f4\u6539\u6570\u7ec4\u957f\u5ea6\uff1f<\/strong><\/p>\n<p>\u5728 Java \u4e2d\uff0c\u4e00\u65e6\u6570\u7ec4\u88ab\u521b\u5efa\uff0c\u5176\u957f\u5ea6\u5c31\u4e0d\u80fd\u88ab\u66f4\u6539\u3002\u6570\u7ec4\u662f\u4e00\u4e2a\u56fa\u5b9a\u5927\u5c0f\u7684\u6570\u636e\u7ed3\u6784\uff0c\u5176\u5927\u5c0f\u5728\u521b\u5efa\u65f6\u6307\u5b9a\u3002\u5982\u679c\u9700\u8981\u66f4\u6539\u6570\u7ec4\u7684\u957f\u5ea6\uff0c\u5219\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u65b0\u6570\u7ec4\u5e76\u590d\u5236\u65e7\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u5982\u4f55\u5728 Java \u4e2d\u8fdb\u884c\u6b64\u64cd\u4f5c\u7684\u65b9\u6cd5\uff1a<\/p>\n<ol>\n<li> <strong>\u521b\u5efa\u65b0\u6570\u7ec4\uff1a<\/strong>\u9996\u5148\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u6570\u7ec4\uff0c\u5176\u957f\u5ea6\u4e3a\u6240\u9700\u5927\u5c0f\u3002<\/li>\n<li> <strong>\u590d\u5236\u5143\u7d20\uff1a<\/strong>\u4f7f\u7528 System.arraycopy() \u65b9\u6cd5\u5c06\u65e7\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u590d\u5236\u5230\u65b0\u6570\u7ec4\u4e2d\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/li>\n<\/ol>\n<pre>int[] oldArray = {1, 2, 3, 4, 5};\nint[] newArray = new int[oldArray.length + 2];\nSystem.arraycopy(oldArray, 0, newArray, 0, oldArray.length);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li> <strong>\u6307\u5411\u65b0\u6570\u7ec4\uff1a<\/strong>\u6700\u540e\uff0c\u5c06\u6570\u7ec4\u53d8\u91cf\u6307\u5411\u65b0\u6570\u7ec4\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/li>\n<\/ol>\n<pre>oldArray = newArray;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u73b0\u5728\uff0coldArray \u5c06\u6307\u5411\u5177\u6709\u65b0\u957f\u5ea6\u7684\u65b0\u6570\u7ec4\u3002\u65e7\u6570\u7ec4\u5c06\u88ab\u5783\u573e\u56de\u6536\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u6f14\u793a\u4e86\u5982\u4f55\u5c06\u957f\u5ea6\u4e3a 5 \u7684\u6570\u7ec4\u6269\u5c55\u5230\u957f\u5ea6\u4e3a 7 \u7684\u6570\u7ec4\uff1a<\/p>\n<pre>int[] oldArray = {1, 2, 3, 4, 5};\nint[] newArray = new int[oldArray.length + 2];\nSystem.arraycopy(oldArray, 0, newArray, 0, oldArray.length);\noldArray = newArray;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6267\u884c\u6b64\u4ee3\u7801\u540e\uff0coldArray \u5c06\u6307\u5411\u4e00\u4e2a\u957f\u5ea6\u4e3a 7 \u7684\u6570\u7ec4\uff0c\u5176\u4e2d\u524d 5 \u4e2a\u5143\u7d20\u4e0e\u6b64\u524d\u76f8\u540c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u4e2d\u600e\u4e48\u66f4\u6539\u6570\u7ec4\u957f\u5ea6\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 java \u4e2d\uff0c\u6570\u7ec4\u957f\u5ea6\u4e0d\u53ef\u53d8\u3002\u8981\u66f4\u6539\u6570\u7ec4\u957f\u5ea6\uff0c\u9700\uff1a\u521b\u5efa\u957f\u5ea6\u4e3a\u6240\u9700\u5927\u5c0f\u7684\u65b0\u6570\u7ec4\u3002\u590d\u5236\u65e7\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u5230\u65b0\u6570\u7ec4\u4e2d\u3002\u5c06\u6570\u7ec4\u53d8\u91cf\u6307\u5411\u65b0\u6570\u7ec4\u3002 \u5982\u4f55\u5728 Java \u4e2d\u66f4\u6539\u6570\u7ec4\u957f\u5ea6\uff1f \u5728 Java \u4e2d\uff0c\u4e00\u65e6\u6570\u7ec4\u88ab\u521b\u5efa\uff0c\u5176\u957f\u5ea6\u5c31\u4e0d\u80fd\u88ab\u66f4\u6539\u3002\u6570\u7ec4\u662f\u4e00\u4e2a\u56fa\u5b9a\u5927\u5c0f\u7684\u6570\u636e\u7ed3\u6784\uff0c\u5176\u5927\u5c0f\u5728\u521b\u5efa\u65f6\u6307\u5b9a\u3002\u5982\u679c\u9700\u8981\u66f4\u6539\u6570\u7ec4\u7684\u957f\u5ea6\uff0c\u5219\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u65b0\u6570\u7ec4\u5e76\u590d\u5236\u65e7\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u3002 \u4ee5\u4e0b\u662f\u5982\u4f55\u5728 Java \u4e2d\u8fdb\u884c\u6b64\u64cd\u4f5c\u7684\u65b9\u6cd5\uff1a \u521b\u5efa\u65b0\u6570\u7ec4\uff1a\u9996\u5148\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u6570\u7ec4\uff0c\u5176\u957f\u5ea6\u4e3a\u6240\u9700\u5927\u5c0f\u3002 \u590d\u5236\u5143\u7d20\uff1a\u4f7f\u7528 System.arraycopy() \u65b9\u6cd5\u5c06\u65e7\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u590d\u5236\u5230\u65b0\u6570\u7ec4\u4e2d\uff0c\u5982\u4e0b\u6240\u793a\uff1a int[] oldArray = {1, 2, 3, 4, 5}; int[] newArray = new int[oldArray.length + 2]; System.arraycopy(oldArray, 0, newArray, 0, oldArray.length); \u767b\u5f55\u540e\u590d\u5236 \u6307\u5411\u65b0\u6570\u7ec4\uff1a\u6700\u540e\uff0c\u5c06\u6570\u7ec4\u53d8\u91cf\u6307\u5411\u65b0\u6570\u7ec4\uff0c\u5982\u4e0b\u6240\u793a\uff1a oldArray = newArray; \u767b\u5f55\u540e\u590d\u5236 \u73b0\u5728\uff0coldArray \u5c06\u6307\u5411\u5177\u6709\u65b0\u957f\u5ea6\u7684\u65b0\u6570\u7ec4\u3002\u65e7\u6570\u7ec4\u5c06\u88ab\u5783\u573e\u56de\u6536\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u793a\u4f8b\uff1a \u4ee5\u4e0b\u4ee3\u7801\u6f14\u793a\u4e86\u5982\u4f55\u5c06\u957f\u5ea6\u4e3a 5 \u7684\u6570\u7ec4\u6269\u5c55\u5230\u957f\u5ea6\u4e3a 7 \u7684\u6570\u7ec4\uff1a int[] oldArray = {1, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-39109","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/39109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=39109"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/39109\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=39109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=39109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=39109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}