{"id":65459,"date":"2025-05-03T11:51:16","date_gmt":"2025-05-03T03:51:16","guid":{"rendered":"https:\/\/fwq.ai\/blog\/65459\/"},"modified":"2025-05-03T11:51:16","modified_gmt":"2025-05-03T03:51:16","slug":"java%e6%80%8e%e4%b9%88%e5%ae%9a%e4%b9%89%e5%ad%97%e7%ac%a6%e5%9e%8b%e6%95%b0%e7%bb%84","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/65459\/","title":{"rendered":"java\u600e\u4e48\u5b9a\u4e49\u5b57\u7b26\u578b\u6570\u7ec4"},"content":{"rendered":"<blockquote><p>\n  \u5728 java \u4e2d\uff0c\u4f7f\u7528 char[] \u53d8\u91cf\u58f0\u660e\u548c\u521d\u59cb\u5316\u5b57\u7b26\u578b\u6570\u7ec4\uff0c\u7136\u540e\u5229\u7528\u7d22\u5f15\u8bbf\u95ee\u548c\u4fee\u6539\u5143\u7d20\uff0c\u901a\u8fc7 .length \u5c5e\u6027\u83b7\u53d6\u6570\u7ec4\u957f\u5ea6\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/13\/2024111301274018076.jpg\" class=\"aligncenter\" title=\"java\u600e\u4e48\u5b9a\u4e49\u5b57\u7b26\u578b\u6570\u7ec4\u63d2\u56fe\" alt=\"java\u600e\u4e48\u5b9a\u4e49\u5b57\u7b26\u578b\u6570\u7ec4\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5b9a\u4e49 Java \u5b57\u7b26\u578b\u6570\u7ec4\uff1f<\/strong><\/p>\n<p><strong>\u89e3\u7b54\uff1a<\/strong><\/p>\n<p>\u8981\u5728 Java \u4e2d\u5b9a\u4e49\u5b57\u7b26\u578b\u6570\u7ec4\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<p><strong>\u6b65\u9aa4 1\uff1a\u58f0\u660e\u6570\u7ec4<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u4f7f\u7528 char[] \u58f0\u660e\u6570\u7ec4\u53d8\u91cf\uff0c\u5176\u4e2d [] \u8868\u793a\u6570\u7ec4\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>char[] myCharArray;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6b65\u9aa4 2\uff1a\u521d\u59cb\u5316\u6570\u7ec4<\/strong><\/p>\n<p>\u6709\u4e24\u79cd\u65b9\u6cd5\u53ef\u4ee5\u521d\u59cb\u5316\u6570\u7ec4\uff1a<\/p>\n<ul>\n<li><strong>\u76f4\u63a5\u521d\u59cb\u5316\uff1a<\/strong><\/li>\n<\/ul>\n<pre>char[] myCharArray = {'a', 'b', 'c', 'd'};<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li><strong>\u4f7f\u7528 new \u64cd\u4f5c\u7b26\uff1a<\/strong><\/li>\n<\/ul>\n<pre>myCharArray = new char[4];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6b65\u9aa4 3\uff1a\u8bbf\u95ee\u6570\u7ec4\u5143\u7d20<\/strong><\/p>\n<p>\u4f7f\u7528\u6570\u7ec4\u7d22\u5f15\u8bbf\u95ee\u6570\u7ec4\u5143\u7d20\u3002\u7d22\u5f15\u4ece 0 \u5f00\u59cb\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>char firstChar = myCharArray[0]; \/\/ \u7ed3\u679c\uff1a'a'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6b65\u9aa4 4\uff1a\u4fee\u6539\u6570\u7ec4\u5143\u7d20<\/strong><\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u7d22\u5f15\u4fee\u6539\u6570\u7ec4\u5143\u7d20\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>myCharArray[2] = 'e'; \/\/ \u4fee\u6539\u7b2c\u4e09\u4e2a\u5143\u7d20\u4e3a 'e'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6b65\u9aa4 5\uff1a\u83b7\u53d6\u6570\u7ec4\u957f\u5ea6<\/strong><\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7 .length \u5c5e\u6027\u83b7\u53d6\u6570\u7ec4\u7684\u957f\u5ea6\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>int length = myCharArray.length; \/\/ \u7ed3\u679c\uff1a4<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u600e\u4e48\u5b9a\u4e49\u5b57\u7b26\u578b\u6570\u7ec4\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\u4f7f\u7528 char[] \u53d8\u91cf\u58f0\u660e\u548c\u521d\u59cb\u5316\u5b57\u7b26\u578b\u6570\u7ec4\uff0c\u7136\u540e\u5229\u7528\u7d22\u5f15\u8bbf\u95ee\u548c\u4fee\u6539\u5143\u7d20\uff0c\u901a\u8fc7 .length \u5c5e\u6027\u83b7\u53d6\u6570\u7ec4\u957f\u5ea6\u3002 \u5982\u4f55\u5b9a\u4e49 Java \u5b57\u7b26\u578b\u6570\u7ec4\uff1f \u89e3\u7b54\uff1a \u8981\u5728 Java \u4e2d\u5b9a\u4e49\u5b57\u7b26\u578b\u6570\u7ec4\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a \u6b65\u9aa4 1\uff1a\u58f0\u660e\u6570\u7ec4 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4f7f\u7528 char[] \u58f0\u660e\u6570\u7ec4\u53d8\u91cf\uff0c\u5176\u4e2d [] \u8868\u793a\u6570\u7ec4\u3002\u4f8b\u5982\uff1a char[] myCharArray; \u767b\u5f55\u540e\u590d\u5236 \u6b65\u9aa4 2\uff1a\u521d\u59cb\u5316\u6570\u7ec4 \u6709\u4e24\u79cd\u65b9\u6cd5\u53ef\u4ee5\u521d\u59cb\u5316\u6570\u7ec4\uff1a \u76f4\u63a5\u521d\u59cb\u5316\uff1a char[] myCharArray = {&#8216;a&#8217;, &#8216;b&#8217;, &#8216;c&#8217;, &#8216;d&#8217;}; \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528 new \u64cd\u4f5c\u7b26\uff1a myCharArray = new char[4]; \u767b\u5f55\u540e\u590d\u5236 \u6b65\u9aa4 3\uff1a\u8bbf\u95ee\u6570\u7ec4\u5143\u7d20 \u4f7f\u7528\u6570\u7ec4\u7d22\u5f15\u8bbf\u95ee\u6570\u7ec4\u5143\u7d20\u3002\u7d22\u5f15\u4ece 0 \u5f00\u59cb\u3002\u4f8b\u5982\uff1a char firstChar = myCharArray[0]; \/\/ [&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-65459","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65459","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=65459"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65459\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=65459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=65459"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=65459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}