{"id":65190,"date":"2025-05-03T15:06:52","date_gmt":"2025-05-03T07:06:52","guid":{"rendered":"https:\/\/fwq.ai\/blog\/65190\/"},"modified":"2025-05-03T15:06:52","modified_gmt":"2025-05-03T07:06:52","slug":"%e6%95%b0%e7%bb%84%e7%9a%84%e5%b8%b8%e7%94%a8%e6%96%b9%e6%b3%95%e6%9c%89%e5%93%aa%e4%ba%9bjava-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/65190\/","title":{"rendered":"\u6570\u7ec4\u7684\u5e38\u7528\u65b9\u6cd5\u6709\u54ea\u4e9bjava"},"content":{"rendered":"<blockquote><p>\n  \u9488\u5bf9java\u6570\u7ec4\u5e38\u7528\u65b9\u6cd5\u7684\u95ee\u9898\uff0c\u6587\u7ae0\u5171\u5217\u51fa\u4e869\u4e2a\u65b9\u6cd5\uff1a\u521b\u5efa\u548c\u521d\u59cb\u5316\u6570\u7ec4\uff1anew int[5]\u6216{1, 2, 3, 4, 5}\u83b7\u53d6\u6570\u7ec4\u957f\u5ea6\uff1a.length\u8bbf\u95ee\u6570\u7ec4\u5143\u7d20\uff1aarr[0]\u4fee\u6539\u6570\u7ec4\u5143\u7d20\uff1aarr[0] = 10\u62f7\u8d1d\u6570\u7ec4\uff1asystem.arraycopy()\u6392\u5e8f\u6570\u7ec4\uff1aarrays.sort()\u641c\u7d22\u6570\u7ec4\u5143\u7d20\uff1aarrays.binarysearch()\u586b\u5145\u6570\u7ec4\u5143\u7d20\uff1aarrays.fill()\u8f6c\u6362\u6570\u7ec4\u4e3astring\uff1aarrays.tostring()\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/12\/2024111210490957126.jpg\" class=\"aligncenter\" title=\"\u6570\u7ec4\u7684\u5e38\u7528\u65b9\u6cd5\u6709\u54ea\u4e9bjava\u63d2\u56fe\" alt=\"\u6570\u7ec4\u7684\u5e38\u7528\u65b9\u6cd5\u6709\u54ea\u4e9bjava\u63d2\u56fe\" \/><\/p>\n<p><strong>Java \u6570\u7ec4\u7684\u5e38\u7528\u65b9\u6cd5<\/strong><\/p>\n<p><strong>\u6570\u7ec4\u7684\u521b\u5efa\u548c\u521d\u59cb\u5316<\/strong><\/p>\n<ul>\n<li>int[] arr = new int[5]; \/\/ \u521b\u5efa\u4e00\u4e2a\u957f\u5ea6\u4e3a 5 \u7684 int \u6570\u7ec4<\/li>\n<li>int[] arr = {1, 2, 3, 4, 5}; \/\/ \u521b\u5efa\u4e00\u4e2a\u5df2\u521d\u59cb\u5316\u7684 int \u6570\u7ec4<\/li>\n<\/ul>\n<p><strong>\u6570\u7ec4\u957f\u5ea6\u7684\u83b7\u53d6<\/strong><\/p>\n<ul>\n<li>arr.length \/\/ \u8fd4\u56de\u6570\u7ec4\u7684\u957f\u5ea6<\/li>\n<\/ul>\n<p><strong>\u6570\u7ec4\u5143\u7d20\u7684\u8bbf\u95ee\u548c\u4fee\u6539<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ul>\n<li>arr[0] \/\/ \u8bbf\u95ee\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20<\/li>\n<li>arr[0] = 10; \/\/ \u4fee\u6539\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20<\/li>\n<\/ul>\n<p><strong>\u6570\u7ec4\u7684\u62f7\u8d1d<\/strong><\/p>\n<ul>\n<li>System.arraycopy(arr, 0, newArr, 0, arr.length); \/\/ \u5c06\u6570\u7ec4 arr \u62f7\u8d1d\u5230 newArr<\/li>\n<\/ul>\n<p><strong>\u6570\u7ec4\u7684\u6392\u5e8f<\/strong><\/p>\n<ul>\n<li>Arrays.sort(arr); \/\/ \u5bf9\u6570\u7ec4\u8fdb\u884c\u6392\u5e8f<\/li>\n<\/ul>\n<p><strong>\u6570\u7ec4\u7684\u641c\u7d22<\/strong><\/p>\n<ul>\n<li>Arrays.binarySearch(arr, 10); \/\/ \u5728\u6570\u7ec4\u4e2d\u4e8c\u5206\u67e5\u627e\u5143\u7d20 10<\/li>\n<\/ul>\n<p><strong>\u6570\u7ec4\u7684\u586b\u5145<\/strong><\/p>\n<ul>\n<li>Arrays.fill(arr, 10); \/\/ \u5c06\u6570\u7ec4\u4e2d\u7684\u6240\u6709\u5143\u7d20\u586b\u5145\u4e3a 10<\/li>\n<\/ul>\n<p><strong>\u6570\u7ec4\u7684\u8f6c\u6362<\/strong><\/p>\n<ul>\n<li>Arrays.toString(arr); \/\/ \u5c06\u6570\u7ec4\u8f6c\u6362\u4e3a String<\/li>\n<\/ul>\n<p><strong>\u6570\u7ec4\u7684\u6bd4\u8f83<\/strong><\/p>\n<ul>\n<li>Arrays.equals(arr, newArr); \/\/ \u6bd4\u8f83\u4e24\u4e2a\u6570\u7ec4\u662f\u5426\u76f8\u7b49<\/li>\n<\/ul>\n<p><strong>\u591a\u7ef4\u6570\u7ec4<\/strong><\/p>\n<ul>\n<li>int[][] arr = new int2; \/\/ \u521b\u5efa\u4e00\u4e2a\u4e8c\u7ef4 int \u6570\u7ec4<\/li>\n<li>arr0 \/\/ \u8bbf\u95ee\u4e8c\u7ef4\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6570\u7ec4\u7684\u5e38\u7528\u65b9\u6cd5\u6709\u54ea\u4e9bjava\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9488\u5bf9java\u6570\u7ec4\u5e38\u7528\u65b9\u6cd5\u7684\u95ee\u9898\uff0c\u6587\u7ae0\u5171\u5217\u51fa\u4e869\u4e2a\u65b9\u6cd5\uff1a\u521b\u5efa\u548c\u521d\u59cb\u5316\u6570\u7ec4\uff1anew int[5]\u6216{1, 2, 3, 4, 5}\u83b7\u53d6\u6570\u7ec4\u957f\u5ea6\uff1a.length\u8bbf\u95ee\u6570\u7ec4\u5143\u7d20\uff1aarr[0]\u4fee\u6539\u6570\u7ec4\u5143\u7d20\uff1aarr[0] = 10\u62f7\u8d1d\u6570\u7ec4\uff1asystem.arraycopy()\u6392\u5e8f\u6570\u7ec4\uff1aarrays.sort()\u641c\u7d22\u6570\u7ec4\u5143\u7d20\uff1aarrays.binarysearch()\u586b\u5145\u6570\u7ec4\u5143\u7d20\uff1aarrays.fill()\u8f6c\u6362\u6570\u7ec4\u4e3astring\uff1aarrays.tostring() Java \u6570\u7ec4\u7684\u5e38\u7528\u65b9\u6cd5 \u6570\u7ec4\u7684\u521b\u5efa\u548c\u521d\u59cb\u5316 int[] arr = new int[5]; \/\/ \u521b\u5efa\u4e00\u4e2a\u957f\u5ea6\u4e3a 5 \u7684 int \u6570\u7ec4 int[] arr = {1, 2, 3, 4, 5}; \/\/ \u521b\u5efa\u4e00\u4e2a\u5df2\u521d\u59cb\u5316\u7684 int \u6570\u7ec4 \u6570\u7ec4\u957f\u5ea6\u7684\u83b7\u53d6 arr.length \/\/ \u8fd4\u56de\u6570\u7ec4\u7684\u957f\u5ea6 \u6570\u7ec4\u5143\u7d20\u7684\u8bbf\u95ee\u548c\u4fee\u6539 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b arr[0] \/\/ \u8bbf\u95ee\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20 arr[0] = 10; \/\/ \u4fee\u6539\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20 \u6570\u7ec4\u7684\u62f7\u8d1d System.arraycopy(arr, 0, newArr, 0, arr.length); \/\/ [&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-65190","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65190","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=65190"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65190\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=65190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=65190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=65190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}