{"id":66015,"date":"2025-05-03T15:42:17","date_gmt":"2025-05-03T07:42:17","guid":{"rendered":"https:\/\/fwq.ai\/blog\/66015\/"},"modified":"2025-05-03T15:42:17","modified_gmt":"2025-05-03T07:42:17","slug":"java-%e6%95%b0%e7%bb%84%e6%80%8e%e4%b9%88%e8%be%93%e5%85%a5%e5%ad%97%e7%ac%a6%e4%b8%b2-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/66015\/","title":{"rendered":"java \u6570\u7ec4\u600e\u4e48\u8f93\u5165\u5b57\u7b26\u4e32"},"content":{"rendered":"<blockquote><p>\n  \u5728 java \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4e24\u79cd\u65b9\u6cd5\u5411\u6570\u7ec4\u4e2d\u8f93\u5165\u5b57\u7b26\u4e32\uff1a\u76f4\u63a5\u8d4b\u503c\uff1astring[] names = {&#8220;john&#8221;, &#8220;mary&#8221;, &#8220;bob&#8221;};\u4f7f\u7528\u6570\u7ec4\u521d\u59cb\u5316\u5668\uff1astring[] names = new string[3]; names[0] = &#8220;john&#8221;; names[1] = &#8220;mary&#8221;; names[2] = &#8220;bob&#8221;;\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/14\/2024111411132076585.jpg\" class=\"aligncenter\" title=\"java \u6570\u7ec4\u600e\u4e48\u8f93\u5165\u5b57\u7b26\u4e32\u63d2\u56fe\" alt=\"java \u6570\u7ec4\u600e\u4e48\u8f93\u5165\u5b57\u7b26\u4e32\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 Java \u4e2d\u5411\u6570\u7ec4\u4e2d\u8f93\u5165\u5b57\u7b26\u4e32<\/strong><\/p>\n<p>\u5728 Java \u4e2d\uff0c\u4f7f\u7528\u6570\u7ec4\u6765\u5b58\u50a8\u5b57\u7b26\u4e32\u975e\u5e38\u7b80\u5355\u3002\u4ee5\u4e0b\u662f\u4e24\u79cd\u65b9\u6cd5\uff1a<\/p>\n<p><strong>\u65b9\u6cd5 1\uff1a\u76f4\u63a5\u8d4b\u503c<\/strong><\/p>\n<pre>String[] names = {\"John\", \"Mary\", \"Bob\"};<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u521d\u59cb\u5316\u65f6\u5df2\u77e5\u6240\u6709\u5b57\u7b26\u4e32\u7684\u60c5\u51b5\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p><strong>\u65b9\u6cd5 2\uff1a\u4f7f\u7528\u6570\u7ec4\u521d\u59cb\u5316\u5668<\/strong><\/p>\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>\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u9700\u8981\u5728\u8fd0\u884c\u65f6\u52a8\u6001\u6dfb\u52a0\u5b57\u7b26\u4e32\u7684\u60c5\u51b5\u3002<\/p>\n<p><strong>\u8be6\u7ec6\u8bf4\u660e\uff1a<\/strong><\/p>\n<ul>\n<li>\n<p><strong>\u65b9\u6cd5 1\uff1a<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528 {} \u521d\u59cb\u5316\u6570\u7ec4\u3002<\/li>\n<li>\u5b57\u7b26\u4e32\u4f7f\u7528\u9017\u53f7\u5206\u9694\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u65b9\u6cd5 2\uff1a<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528 new \u5173\u952e\u5b57\u521b\u5efa\u4e00\u4e2a\u65b0\u6570\u7ec4\u3002<\/li>\n<li>\u4f7f\u7528 [] \u8bbf\u95ee\u6570\u7ec4\u5143\u7d20\u5e76\u8d4b\u503c\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>\u786e\u4fdd\u6570\u7ec4\u5927\u5c0f\u8db3\u591f\u5bb9\u7eb3\u6240\u6709\u5b57\u7b26\u4e32\u3002<\/li>\n<li>\u5bf9\u4e8e\u65b9\u6cd5 2\uff0c\u52a1\u5fc5\u5728\u8bbf\u95ee\u5143\u7d20\u4e4b\u524d\u521d\u59cb\u5316\u5b83\u4eec\uff0c\u5426\u5219\u4f1a\u51fa\u73b0 NullPointerException\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fjava \u6570\u7ec4\u600e\u4e48\u8f93\u5165\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>\u5728 java \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4e24\u79cd\u65b9\u6cd5\u5411\u6570\u7ec4\u4e2d\u8f93\u5165\u5b57\u7b26\u4e32\uff1a\u76f4\u63a5\u8d4b\u503c\uff1astring[] names = {&#8220;john&#8221;, &#8220;mary&#8221;, &#8220;bob&#8221;};\u4f7f\u7528\u6570\u7ec4\u521d\u59cb\u5316\u5668\uff1astring[] names = new string[3]; names[0] = &#8220;john&#8221;; names[1] = &#8220;mary&#8221;; names[2] = &#8220;bob&#8221;; \u5982\u4f55\u5728 Java \u4e2d\u5411\u6570\u7ec4\u4e2d\u8f93\u5165\u5b57\u7b26\u4e32 \u5728 Java \u4e2d\uff0c\u4f7f\u7528\u6570\u7ec4\u6765\u5b58\u50a8\u5b57\u7b26\u4e32\u975e\u5e38\u7b80\u5355\u3002\u4ee5\u4e0b\u662f\u4e24\u79cd\u65b9\u6cd5\uff1a \u65b9\u6cd5 1\uff1a\u76f4\u63a5\u8d4b\u503c String[] names = {&#8220;John&#8221;, &#8220;Mary&#8221;, &#8220;Bob&#8221;}; \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u521d\u59cb\u5316\u65f6\u5df2\u77e5\u6240\u6709\u5b57\u7b26\u4e32\u7684\u60c5\u51b5\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u65b9\u6cd5 2\uff1a\u4f7f\u7528\u6570\u7ec4\u521d\u59cb\u5316\u5668 String[] names = new String[3]; names[0] = &#8220;John&#8221;; names[1] = &#8220;Mary&#8221;; names[2] = &#8220;Bob&#8221;; \u767b\u5f55\u540e\u590d\u5236 [&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-66015","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66015","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=66015"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66015\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=66015"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=66015"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=66015"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}