{"id":65953,"date":"2025-05-03T14:25:21","date_gmt":"2025-05-03T06:25:21","guid":{"rendered":"https:\/\/fwq.ai\/blog\/65953\/"},"modified":"2025-05-03T14:25:21","modified_gmt":"2025-05-03T06:25:21","slug":"java-%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%95%b0%e7%bb%84%e6%80%8e%e4%b9%88%e5%ae%9a%e4%b9%89-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/65953\/","title":{"rendered":"java \u5b57\u7b26\u4e32\u6570\u7ec4\u600e\u4e48\u5b9a\u4e49"},"content":{"rendered":"<blockquote><p>\n  java \u5b57\u7b26\u4e32\u6570\u7ec4\u5b9a\u4e49\u901a\u8fc7 string[] arrayname = new string[size]; \u8bed\u6cd5\uff0c\u5176\u4e2d arrayname \u4e3a\u6570\u7ec4\u540d\u79f0\uff0csize \u4e3a\u5143\u7d20\u6570\u91cf\u3002\u5b9a\u4e49\u65f6\u53ef\u521d\u59cb\u5316\uff0c\u5982 string[] names = {&#8220;john&#8221;, &#8220;mary&#8221;,&#8230;}\u3002\u8bbf\u95ee\u5143\u7d20\u7528\u7d22\u5f15\uff0c\u5982 names[0]\u3002\u904d\u5386\u6570\u7ec4\u7528 for \u5faa\u73af\uff0c\u5982 for (int i = 0; i <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/13\/2024111317071642680.jpg\" class=\"aligncenter\" title=\"java \u5b57\u7b26\u4e32\u6570\u7ec4\u600e\u4e48\u5b9a\u4e49\u63d2\u56fe\" alt=\"java \u5b57\u7b26\u4e32\u6570\u7ec4\u600e\u4e48\u5b9a\u4e49\u63d2\u56fe\" \/><\/p>\n<p><strong>Java \u7684\u5b9a\u4e49<\/strong><\/p>\n<p><strong>\u5b9a\u4e49\u8bed\u6cd5\uff1a<\/strong><\/p>\n<pre>String[] arrayName = new String[size];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u6b64\u8bed\u6cd5\u4e2d\uff1a<\/p>\n<ul>\n<li>arrayName \u662f\u5b57\u7b26\u4e32\u6570\u7ec4\u7684\u540d\u79f0\u3002<\/li>\n<li>size \u662f\u6570\u7ec4\u4e2d\u5143\u7d20\u7684\u6570\u91cf\u3002<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>String[] names = new String[5];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u5927\u5c0f\u4e3a 5 \u7684\u5b57\u7b26\u4e32\u6570\u7ec4\uff0c\u540d\u4e3a names\u3002<\/p>\n<p><strong>\u521d\u59cb\u5316\u6570\u7ec4\uff1a<\/strong><\/p>\n<p>\u5b57\u7b26\u4e32\u6570\u7ec4\u53ef\u4ee5\u5728\u5b9a\u4e49\u65f6\u521d\u59cb\u5316\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>String[] names = { \"John\", \"Mary\", \"Bob\", \"Alice\", \"Tom\" };<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8bbf\u95ee\u6570\u7ec4\u5143\u7d20\uff1a<\/strong><\/p>\n<p>\u8981\u8bbf\u95ee\u6570\u7ec4\u5143\u7d20\uff0c\u53ef\u4ee5\u4f7f\u7528\u7d22\u5f15\u503c\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>String name = names[0]; \/\/ \u8bbf\u95ee\u7b2c\u4e00\u4e2a\u5143\u7d20<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u904d\u5386\u6570\u7ec4\uff1a<\/strong><\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528 for \u5faa\u73af\u904d\u5386\u6570\u7ec4\u4e2d\u7684\u6240\u6709\u5143\u7d20\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>for (int i = 0; i &lt; names.length; i++) {\n    String name = names[i];\n    \/\/ \u5904\u7406 name\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236\n<\/p><\/blockquote>\n<p>\u4ee5\u4e0a\u5c31\u662fjava \u600e\u4e48\u5b9a\u4e49\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>java \u5b57\u7b26\u4e32\u6570\u7ec4\u5b9a\u4e49\u901a\u8fc7 string[] arrayname = new string[size]; \u8bed\u6cd5\uff0c\u5176\u4e2d arrayname \u4e3a\u6570\u7ec4\u540d\u79f0\uff0csize \u4e3a\u5143\u7d20\u6570\u91cf\u3002\u5b9a\u4e49\u65f6\u53ef\u521d\u59cb\u5316\uff0c\u5982 string[] names = {&#8220;john&#8221;, &#8220;mary&#8221;,&#8230;}\u3002\u8bbf\u95ee\u5143\u7d20\u7528\u7d22\u5f15\uff0c\u5982 names[0]\u3002\u904d\u5386\u6570\u7ec4\u7528 for \u5faa\u73af\uff0c\u5982 for (int i = 0; i Java \u7684\u5b9a\u4e49 \u5b9a\u4e49\u8bed\u6cd5\uff1a String[] arrayName = new String[size]; \u767b\u5f55\u540e\u590d\u5236 \u5728\u6b64\u8bed\u6cd5\u4e2d\uff1a arrayName \u662f\u5b57\u7b26\u4e32\u6570\u7ec4\u7684\u540d\u79f0\u3002 size \u662f\u6570\u7ec4\u4e2d\u5143\u7d20\u7684\u6570\u91cf\u3002 \u793a\u4f8b\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b String[] names = new String[5]; \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u5927\u5c0f\u4e3a 5 \u7684\u5b57\u7b26\u4e32\u6570\u7ec4\uff0c\u540d\u4e3a names\u3002 \u521d\u59cb\u5316\u6570\u7ec4\uff1a \u5b57\u7b26\u4e32\u6570\u7ec4\u53ef\u4ee5\u5728\u5b9a\u4e49\u65f6\u521d\u59cb\u5316\uff0c\u5982\u4e0b\u6240\u793a\uff1a String[] names [&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-65953","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65953","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=65953"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65953\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=65953"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=65953"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=65953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}