{"id":37323,"date":"2024-11-26T15:31:45","date_gmt":"2024-11-26T07:31:45","guid":{"rendered":"https:\/\/fwq.ai\/blog\/37323\/"},"modified":"2024-11-26T15:31:45","modified_gmt":"2024-11-26T07:31:45","slug":"java%e5%ad%97%e7%ac%a6%e5%9e%8b%e6%95%b0%e7%bb%84%e6%80%8e%e4%b9%88%e5%ae%9a%e4%b9%89","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/37323\/","title":{"rendered":"java\u5b57\u7b26\u578b\u6570\u7ec4\u600e\u4e48\u5b9a\u4e49"},"content":{"rendered":"<blockquote><p>\n  java \u5b57\u7b26\u578b\u6570\u7ec4\u5b9a\u4e49\u65b9\u6cd5\u5305\u62ec\uff1a1. \u8bed\u6cd5\uff1achar[] arrayname = new char[size]\uff0c\u5176\u4e2d arrayname \u4e3a\u540d\u79f0\uff0csize \u4e3a\u5927\u5c0f\uff1b2. \u521d\u59cb\u5316\u5143\u7d20\uff1avowels[i] = &#8216;character&#8217;\uff0c\u5176\u4e2d vowels \u4e3a\u6570\u7ec4\u540d\uff0ci \u4e3a\u4e0b\u6807\uff0c&#8217;character&#8217; \u4e3a\u5b57\u7b26\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/13\/2024111303571661664.jpg\" class=\"aligncenter\" title=\"java\u5b57\u7b26\u578b\u6570\u7ec4\u600e\u4e48\u5b9a\u4e49\u63d2\u56fe\" alt=\"java\u5b57\u7b26\u578b\u6570\u7ec4\u600e\u4e48\u5b9a\u4e49\u63d2\u56fe\" \/><\/p>\n<p><strong>Java \u5b57\u7b26\u578b\u6570\u7ec4\u5b9a\u4e49<\/strong><\/p>\n<p><strong>\u5b9a\u4e49\u65b9\u5f0f\uff1a<\/strong><\/p>\n<p>\u8981\u5728 Java \u4e2d\u5b9a\u4e49\u4e00\u4e2a\u5b57\u7b26\u578b\u6570\u7ec4\uff0c\u9700\u8981\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a<\/p>\n<pre>char[] arrayName = new char[size];<\/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> <strong>arrayName<\/strong> \u662f\u6570\u7ec4\u7684\u540d\u79f0\u3002<\/li>\n<li> <strong>size<\/strong> \u662f\u6570\u7ec4\u7684\u5927\u5c0f\uff0c\u6307\u5b9a\u6570\u7ec4\u53ef\u4ee5\u5bb9\u7eb3\u7684\u5b57\u7b26\u6570\u91cf\u3002<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>char[] vowels = new char[5];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u4ee3\u7801\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3a vowels \u7684\u5b57\u7b26\u578b\u6570\u7ec4\uff0c\u8be5\u6570\u7ec4\u7684\u5927\u5c0f\u4e3a 5\uff0c\u53ef\u4ee5\u5bb9\u7eb3 5 \u4e2a\u5b57\u7b26\u3002<\/p>\n<p><strong>\u6570\u7ec4\u5143\u7d20\u521d\u59cb\u5316\uff1a<\/strong><\/p>\n<p>\u5b9a\u4e49\u6570\u7ec4\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u5f0f\u521d\u59cb\u5316\u6570\u7ec4\u5143\u7d20\uff1a<\/p>\n<pre>vowels[0] = 'a';\nvowels[1] = 'e';\nvowels[2] = 'i';\nvowels[3] = 'o';\nvowels[4] = 'u';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u4ee3\u7801\u5c06 vowels \u6570\u7ec4\u7684\u5143\u7d20\u521d\u59cb\u5316\u4e3a\u5143\u97f3\u5b57\u6bcd\u3002<\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>\u5b57\u7b26\u578b\u6570\u7ec4\u7684\u9ed8\u8ba4\u503c\u662f &#8216;u0000&#8217;\uff08\u7a7a\u5b57\u7b26\uff09\u3002<\/li>\n<li>\u6570\u7ec4\u7684\u5927\u5c0f\u5fc5\u987b\u5728\u5b9a\u4e49\u65f6\u6307\u5b9a\uff0c\u4e0d\u80fd\u5728\u4e4b\u540e\u8fdb\u884c\u66f4\u6539\u3002<\/li>\n<li>\u6570\u7ec4\u5143\u7d20\u7684\u4e0b\u6807\u4ece 0 \u5f00\u59cb\uff0c\u5230 size-1 \u7ed3\u675f\u3002\u8bbf\u95ee\u8d85\u51fa\u6b64\u8303\u56f4\u7684\u4e0b\u6807\u4f1a\u5f15\u53d1 ArrayIndexOutOfBoundsException\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u5b57\u7b26\u578b\u6570\u7ec4\u600e\u4e48\u5b9a\u4e49\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>java \u5b57\u7b26\u578b\u6570\u7ec4\u5b9a\u4e49\u65b9\u6cd5\u5305\u62ec\uff1a1. \u8bed\u6cd5\uff1achar[] arrayname = new char[size]\uff0c\u5176\u4e2d arrayname \u4e3a\u540d\u79f0\uff0csize \u4e3a\u5927\u5c0f\uff1b2. \u521d\u59cb\u5316\u5143\u7d20\uff1avowels[i] = &#8216;character&#8217;\uff0c\u5176\u4e2d vowels \u4e3a\u6570\u7ec4\u540d\uff0ci \u4e3a\u4e0b\u6807\uff0c&#8217;character&#8217; \u4e3a\u5b57\u7b26\u3002 Java \u5b57\u7b26\u578b\u6570\u7ec4\u5b9a\u4e49 \u5b9a\u4e49\u65b9\u5f0f\uff1a \u8981\u5728 Java \u4e2d\u5b9a\u4e49\u4e00\u4e2a\u5b57\u7b26\u578b\u6570\u7ec4\uff0c\u9700\u8981\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a char[] arrayName = new char[size]; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b arrayName \u662f\u6570\u7ec4\u7684\u540d\u79f0\u3002 size \u662f\u6570\u7ec4\u7684\u5927\u5c0f\uff0c\u6307\u5b9a\u6570\u7ec4\u53ef\u4ee5\u5bb9\u7eb3\u7684\u5b57\u7b26\u6570\u91cf\u3002 \u793a\u4f8b\uff1a char[] vowels = new char[5]; \u767b\u5f55\u540e\u590d\u5236 \u6b64\u4ee3\u7801\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3a vowels \u7684\u5b57\u7b26\u578b\u6570\u7ec4\uff0c\u8be5\u6570\u7ec4\u7684\u5927\u5c0f\u4e3a 5\uff0c\u53ef\u4ee5\u5bb9\u7eb3 5 \u4e2a\u5b57\u7b26\u3002 \u6570\u7ec4\u5143\u7d20\u521d\u59cb\u5316\uff1a \u5b9a\u4e49\u6570\u7ec4\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u5f0f\u521d\u59cb\u5316\u6570\u7ec4\u5143\u7d20\uff1a vowels[0] = &#8216;a&#8217;; vowels[1] = [&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-37323","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/37323","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=37323"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/37323\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=37323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=37323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=37323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}