{"id":66563,"date":"2025-05-03T12:45:46","date_gmt":"2025-05-03T04:45:46","guid":{"rendered":"https:\/\/fwq.ai\/blog\/66563\/"},"modified":"2025-05-03T12:45:46","modified_gmt":"2025-05-03T04:45:46","slug":"java%e4%b8%ad%e6%95%b0%e7%bb%84%e6%80%8e%e4%b9%88%e5%ae%9a%e4%b9%89%e5%ad%97%e7%ac%a6%e4%b8%b2-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/66563\/","title":{"rendered":"java\u4e2d\u6570\u7ec4\u600e\u4e48\u5b9a\u4e49\u5b57\u7b26\u4e32"},"content":{"rendered":"<blockquote><p>\n  java \u4e2d\u5b9a\u4e49\u5b57\u7b26\u4e32\u6570\u7ec4\u5206\u4e3a\u4e24\u4e2a\u6b65\u9aa4\uff1a\u58f0\u660e\u6570\u7ec4\u5e76\u6307\u5b9a\u5176\u7c7b\u578b\uff0c\u4f8b\u5982\uff1astring[] names;\u3002\u7136\u540e\uff0c\u4f7f\u7528\u76f4\u63a5\u521d\u59cb\u5316\uff08string[] names = {&#8220;john&#8221;, &#8220;mary&#8221;, &#8220;bob&#8221;};\uff09\u6216\u52a8\u6001\u521d\u59cb\u5316\uff08string[] names = new string[3];\uff09\u6765\u521d\u59cb\u5316\u6570\u7ec4\u5e76\u6307\u5b9a\u5143\u7d20\u503c\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/16\/2024111606302197774.jpg\" class=\"aligncenter\" title=\"java\u4e2d\u6570\u7ec4\u600e\u4e48\u5b9a\u4e49\u5b57\u7b26\u4e32\u63d2\u56fe\" alt=\"java\u4e2d\u6570\u7ec4\u600e\u4e48\u5b9a\u4e49\u5b57\u7b26\u4e32\u63d2\u56fe\" \/><\/p>\n<p><strong>Java \u4e2d\u5b9a\u4e49\u7684\u65b9\u6cd5<\/strong><\/p>\n<p><strong>\u5b9a\u4e49<\/strong><\/p>\n<p>\u5728 Java \u4e2d\uff0c\u5b57\u7b26\u4e32\u6570\u7ec4\u662f\u4e00\u4e2a\u5b58\u50a8\u5b57\u7b26\u4e32\u96c6\u5408\u7684\u6570\u636e\u7ed3\u6784\uff0c\u53ef\u4ee5\u6309\u7d22\u5f15\u8bbf\u95ee\u6bcf\u4e2a\u5143\u7d20\u3002\u8981\u5b9a\u4e49\u5b57\u7b26\u4e32\u6570\u7ec4\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a<\/p>\n<pre>String[] names[];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ul>\n<li>String[] \u6307\u5b9a\u6570\u7ec4\u7684\u7c7b\u578b\u4e3a\u5b57\u7b26\u4e32\u6570\u7ec4\u3002<\/li>\n<li>names \u662f\u6570\u7ec4\u7684\u540d\u79f0\u3002<\/li>\n<li>[] \u8868\u793a\u8fd9\u662f\u4e00\u7ef4\u6570\u7ec4\uff08\u5373\uff0c\u5b83\u53ea\u5305\u542b\u4e00\u4e2a\u5c42\u7ea7\u7684\u5143\u7d20\uff09\u3002<\/li>\n<\/ul>\n<p><strong>\u521d\u59cb\u5316<\/strong><\/p>\n<p>\u5b9a\u4e49\u6570\u7ec4\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4e24\u79cd\u65b9\u5f0f\u5bf9\u5176\u8fdb\u884c\u521d\u59cb\u5316\uff1a<\/p>\n<ul>\n<li> <strong>\u76f4\u63a5\u521d\u59cb\u5316\uff1a<\/strong>\u5728\u6570\u7ec4\u5b9a\u4e49\u65f6\u76f4\u63a5\u6307\u5b9a\u5143\u7d20\u503c\u3002\u4f8b\u5982\uff1a<\/li>\n<\/ul>\n<pre>String[] names = {\"John\", \"Mary\", \"Bob\"};<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li> <strong>\u52a8\u6001\u521d\u59cb\u5316\uff1a<\/strong>\u4f7f\u7528 new \u8fd0\u7b97\u7b26\u521b\u5efa\u4e00\u4e2a\u65b0\u6570\u7ec4\uff0c\u7136\u540e\u4f7f\u7528\u7d22\u5f15\u8d4b\u503c\u5143\u7d20\u3002\u4f8b\u5982\uff1a<\/li>\n<\/ul>\n<pre>String[] names = new String[3];\nnames[0] = \"John\";\nnames[1] = \"Mary\";\nnames[2] = \"Bob\";<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528\u5b57\u7b26\u4e32\u6570\u7ec4\u7684\u793a\u4f8b\uff1a<\/p>\n<pre>\/\/ \u5b9a\u4e49\u4e00\u4e2a\u5b58\u50a8\u5b66\u751f\u59d3\u540d\u7684\u5b57\u7b26\u4e32\u6570\u7ec4\nString[] studentNames = {\"Alice\", \"Bob\", \"Cathy\", \"Dave\"};\n\n\/\/ \u5faa\u73af\u8bbf\u95ee\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\nfor (String name : studentNames) {\n    System.out.println(name);\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8f93\u51fa\uff1a<\/strong><\/p>\n<pre>Alice\nBob\nCathy\nDave<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u4e2d\u6570\u7ec4\u600e\u4e48\u5b9a\u4e49\u5b57\u7b26\u4e32\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 \u4e2d\u5b9a\u4e49\u5b57\u7b26\u4e32\u6570\u7ec4\u5206\u4e3a\u4e24\u4e2a\u6b65\u9aa4\uff1a\u58f0\u660e\u6570\u7ec4\u5e76\u6307\u5b9a\u5176\u7c7b\u578b\uff0c\u4f8b\u5982\uff1astring[] names;\u3002\u7136\u540e\uff0c\u4f7f\u7528\u76f4\u63a5\u521d\u59cb\u5316\uff08string[] names = {&#8220;john&#8221;, &#8220;mary&#8221;, &#8220;bob&#8221;};\uff09\u6216\u52a8\u6001\u521d\u59cb\u5316\uff08string[] names = new string[3];\uff09\u6765\u521d\u59cb\u5316\u6570\u7ec4\u5e76\u6307\u5b9a\u5143\u7d20\u503c\u3002 Java \u4e2d\u5b9a\u4e49\u7684\u65b9\u6cd5 \u5b9a\u4e49 \u5728 Java \u4e2d\uff0c\u5b57\u7b26\u4e32\u6570\u7ec4\u662f\u4e00\u4e2a\u5b58\u50a8\u5b57\u7b26\u4e32\u96c6\u5408\u7684\u6570\u636e\u7ed3\u6784\uff0c\u53ef\u4ee5\u6309\u7d22\u5f15\u8bbf\u95ee\u6bcf\u4e2a\u5143\u7d20\u3002\u8981\u5b9a\u4e49\u5b57\u7b26\u4e32\u6570\u7ec4\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a String[] names[]; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b String[] \u6307\u5b9a\u6570\u7ec4\u7684\u7c7b\u578b\u4e3a\u5b57\u7b26\u4e32\u6570\u7ec4\u3002 names \u662f\u6570\u7ec4\u7684\u540d\u79f0\u3002 [] \u8868\u793a\u8fd9\u662f\u4e00\u7ef4\u6570\u7ec4\uff08\u5373\uff0c\u5b83\u53ea\u5305\u542b\u4e00\u4e2a\u5c42\u7ea7\u7684\u5143\u7d20\uff09\u3002 \u521d\u59cb\u5316 \u5b9a\u4e49\u6570\u7ec4\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4e24\u79cd\u65b9\u5f0f\u5bf9\u5176\u8fdb\u884c\u521d\u59cb\u5316\uff1a \u76f4\u63a5\u521d\u59cb\u5316\uff1a\u5728\u6570\u7ec4\u5b9a\u4e49\u65f6\u76f4\u63a5\u6307\u5b9a\u5143\u7d20\u503c\u3002\u4f8b\u5982\uff1a String[] names = {&#8220;John&#8221;, &#8220;Mary&#8221;, &#8220;Bob&#8221;}; \u767b\u5f55\u540e\u590d\u5236 \u52a8\u6001\u521d\u59cb\u5316\uff1a\u4f7f\u7528 new \u8fd0\u7b97\u7b26\u521b\u5efa\u4e00\u4e2a\u65b0\u6570\u7ec4\uff0c\u7136\u540e\u4f7f\u7528\u7d22\u5f15\u8d4b\u503c\u5143\u7d20\u3002\u4f8b\u5982\uff1a String[] names = new String[3]; names[0] = &#8220;John&#8221;; names[1] = &#8220;Mary&#8221;; names[2] = [&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-66563","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66563","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=66563"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66563\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=66563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=66563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=66563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}