{"id":34484,"date":"2024-11-26T16:37:32","date_gmt":"2024-11-26T08:37:32","guid":{"rendered":"https:\/\/fwq.ai\/blog\/34484\/"},"modified":"2024-11-26T16:37:32","modified_gmt":"2024-11-26T08:37:32","slug":"java%e4%b8%80%e7%bb%b4%e6%95%b0%e7%bb%84%e6%80%8e%e4%b9%88%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/34484\/","title":{"rendered":"java\u4e00\u7ef4\u6570\u7ec4\u600e\u4e48\u6dfb\u52a0\u6570\u636e"},"content":{"rendered":"<blockquote><p>\n  \u5728 java \u4e2d\uff0c\u5411\u4e00\u7ef4\u6570\u7ec4\u6dfb\u52a0\u6570\u636e\u9700\u8981\u5148\u521b\u5efa\u548c\u521d\u59cb\u5316\u6570\u7ec4\uff0c\u7136\u540e\u901a\u8fc7\u7d22\u5f15\u8bbf\u95ee\u548c\u8bbe\u7f6e\u5143\u7d20\u3002\u5177\u4f53\u6b65\u9aa4\u4e3a\uff1a1. \u521b\u5efa\u5e76\u521d\u59cb\u5316\u6570\u7ec4\uff1b2. \u4f7f\u7528\u7d22\u5f15\u8bbf\u95ee\u5143\u7d20\uff1b3. \u901a\u8fc7\u7d22\u5f15\u8bbe\u7f6e\u5143\u7d20\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/02\/2024110214550999950.jpg\" class=\"aligncenter\" title=\"java\u4e00\u7ef4\u6570\u7ec4\u600e\u4e48\u6dfb\u52a0\u6570\u636e\u63d2\u56fe\" alt=\"java\u4e00\u7ef4\u6570\u7ec4\u600e\u4e48\u6dfb\u52a0\u6570\u636e\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 Java \u4e2d\u5411\u4e00\u7ef4\u6570\u7ec4\u6dfb\u52a0\u6570\u636e<\/strong><\/p>\n<p>Java \u4e2d\u7684\u4e00\u7ef4\u6570\u7ec4\u662f\u4e00\u79cd\u5b58\u50a8\u76f8\u540c\u6570\u636e\u7c7b\u578b\u7684\u5143\u7d20\u7684\u6709\u5e8f\u96c6\u5408\u3002\u8981\u5411\u4e00\u7ef4\u6570\u7ec4\u6dfb\u52a0\u6570\u636e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u521b\u5efa\u548c\u521d\u59cb\u5316\u6570\u7ec4<\/strong><\/p>\n<p>\u9996\u5148\uff0c\u521b\u5efa\u5e76\u521d\u59cb\u5316\u4e00\u4e2a\u4e00\u7ef4\u6570\u7ec4\u3002\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>int[] arrayName = new int[size];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li>arrayName \u662f\u6570\u7ec4\u7684\u540d\u79f0\u3002<\/li>\n<li>size \u662f\u6570\u7ec4\u7684\u5927\u5c0f\uff0c\u8868\u793a\u53ef\u5bb9\u7eb3\u7684\u5143\u7d20\u6570\u91cf\u3002<\/li>\n<\/ul>\n<p><strong>2. \u4f7f\u7528\u7d22\u5f15\u8bbf\u95ee\u5143\u7d20<\/strong><\/p>\n<p>\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u90fd\u901a\u8fc7\u4e00\u4e2a\u79f0\u4e3a\u7d22\u5f15\u7684\u6574\u6570\u8bbf\u95ee\u3002\u7d22\u5f15\u4ece 0 \u5f00\u59cb\uff0c\u5230\u8fbe\u6570\u7ec4\u7684\u957f\u5ea6\u51cf\u4e00\u4e3a\u7ed3\u675f\u3002<\/p>\n<p><strong>3. \u901a\u8fc7\u7d22\u5f15\u8bbe\u7f6e\u5143\u7d20<\/strong><\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u7d22\u5f15\u4e3a\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u8d4b\u503c\u3002\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>arrayName[index] = value;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li>index \u662f\u8981\u8bbe\u7f6e\u503c\u7684\u5143\u7d20\u7684\u7d22\u5f15\u3002<\/li>\n<li>value \u662f\u8981\u8d4b\u4e88\u5143\u7d20\u7684\u503c\u3002<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>int[] numbers = new int[5];\nnumbers[0] = 10;\nnumbers[1] = 20;\nnumbers[2] = 30;\nnumbers[3] = 40;\nnumbers[4] = 50;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728\u5411\u6570\u7ec4\u4e2d\u6dfb\u52a0\u6570\u636e\u4e4b\u524d\uff0c\u5fc5\u987b\u5148\u5bf9\u5176\u8fdb\u884c\u521d\u59cb\u5316\u3002<\/li>\n<li>\u7d22\u5f15\u5fc5\u987b\u5728\u6570\u7ec4\u7684\u6709\u6548\u8303\u56f4\u5185\uff080 \u5230\u6570\u7ec4\u957f\u5ea6\u51cf\u4e00\uff09\u3002<\/li>\n<li>\u8d85\u51fa\u6570\u7ec4\u8303\u56f4\u7684\u7d22\u5f15\u4f1a\u5bfc\u81f4\u6570\u7ec4\u8d8a\u754c\u5f02\u5e38\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u4e00\u7ef4\u6570\u7ec4\u600e\u4e48\u6dfb\u52a0\u6570\u636e\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\u5411\u4e00\u7ef4\u6570\u7ec4\u6dfb\u52a0\u6570\u636e\u9700\u8981\u5148\u521b\u5efa\u548c\u521d\u59cb\u5316\u6570\u7ec4\uff0c\u7136\u540e\u901a\u8fc7\u7d22\u5f15\u8bbf\u95ee\u548c\u8bbe\u7f6e\u5143\u7d20\u3002\u5177\u4f53\u6b65\u9aa4\u4e3a\uff1a1. \u521b\u5efa\u5e76\u521d\u59cb\u5316\u6570\u7ec4\uff1b2. \u4f7f\u7528\u7d22\u5f15\u8bbf\u95ee\u5143\u7d20\uff1b3. \u901a\u8fc7\u7d22\u5f15\u8bbe\u7f6e\u5143\u7d20\u3002 \u5982\u4f55\u5728 Java \u4e2d\u5411\u4e00\u7ef4\u6570\u7ec4\u6dfb\u52a0\u6570\u636e Java \u4e2d\u7684\u4e00\u7ef4\u6570\u7ec4\u662f\u4e00\u79cd\u5b58\u50a8\u76f8\u540c\u6570\u636e\u7c7b\u578b\u7684\u5143\u7d20\u7684\u6709\u5e8f\u96c6\u5408\u3002\u8981\u5411\u4e00\u7ef4\u6570\u7ec4\u6dfb\u52a0\u6570\u636e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\uff1a 1. \u521b\u5efa\u548c\u521d\u59cb\u5316\u6570\u7ec4 \u9996\u5148\uff0c\u521b\u5efa\u5e76\u521d\u59cb\u5316\u4e00\u4e2a\u4e00\u7ef4\u6570\u7ec4\u3002\u8bed\u6cd5\u5982\u4e0b\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b int[] arrayName = new int[size]; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a arrayName \u662f\u6570\u7ec4\u7684\u540d\u79f0\u3002 size \u662f\u6570\u7ec4\u7684\u5927\u5c0f\uff0c\u8868\u793a\u53ef\u5bb9\u7eb3\u7684\u5143\u7d20\u6570\u91cf\u3002 2. \u4f7f\u7528\u7d22\u5f15\u8bbf\u95ee\u5143\u7d20 \u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u90fd\u901a\u8fc7\u4e00\u4e2a\u79f0\u4e3a\u7d22\u5f15\u7684\u6574\u6570\u8bbf\u95ee\u3002\u7d22\u5f15\u4ece 0 \u5f00\u59cb\uff0c\u5230\u8fbe\u6570\u7ec4\u7684\u957f\u5ea6\u51cf\u4e00\u4e3a\u7ed3\u675f\u3002 3. \u901a\u8fc7\u7d22\u5f15\u8bbe\u7f6e\u5143\u7d20 \u53ef\u4ee5\u901a\u8fc7\u7d22\u5f15\u4e3a\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u8d4b\u503c\u3002\u8bed\u6cd5\u5982\u4e0b\uff1a arrayName[index] = value; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a index \u662f\u8981\u8bbe\u7f6e\u503c\u7684\u5143\u7d20\u7684\u7d22\u5f15\u3002 value \u662f\u8981\u8d4b\u4e88\u5143\u7d20\u7684\u503c\u3002 \u793a\u4f8b\uff1a int[] numbers = new int[5]; numbers[0] = 10; numbers[1] = 20; [&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-34484","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/34484","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=34484"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/34484\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=34484"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=34484"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=34484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}