{"id":38580,"date":"2024-11-26T09:33:00","date_gmt":"2024-11-26T01:33:00","guid":{"rendered":"https:\/\/fwq.ai\/blog\/38580\/"},"modified":"2024-11-26T09:33:00","modified_gmt":"2024-11-26T01:33:00","slug":"java%e5%ad%97%e7%ac%a6%e6%95%b0%e7%bb%84%e6%80%8e%e4%b9%88%e5%8f%98%e6%88%90%e5%ad%97%e7%ac%a6%e4%b8%b2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/38580\/","title":{"rendered":"java\u5b57\u7b26\u6570\u7ec4\u600e\u4e48\u53d8\u6210\u5b57\u7b26\u4e32"},"content":{"rendered":"<blockquote><p>\n  \u8981\u5c06\u5b57\u7b26\u6570\u7ec4\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528 string \u6784\u9020\u51fd\u6570\u6216 stringbuilder \u7c7b\u3002 string \u6784\u9020\u51fd\u6570\u9002\u5408\u5904\u7406\u4e0d\u53ef\u53d8\u5b57\u7b26\u6570\u7ec4\uff0c\u800c stringbuilder \u7c7b\u66f4\u9002\u5408\u5904\u7406\u53ef\u53d8\u5b57\u7b26\u6570\u7ec4\u6216\u9700\u8981\u4fee\u6539\u5b57\u7b26\u4e32\u7684\u60c5\u51b5\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/15\/2024111503272421807.jpg\" class=\"aligncenter\" title=\"java\u5b57\u7b26\u6570\u7ec4\u600e\u4e48\u53d8\u6210\u5b57\u7b26\u4e32\u63d2\u56fe\" alt=\"java\u5b57\u7b26\u6570\u7ec4\u600e\u4e48\u53d8\u6210\u5b57\u7b26\u4e32\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 Java \u4e2d\u5c06\u5b57\u7b26\u6570\u7ec4\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32<\/strong><\/p>\n<p><strong>\u5f00\u95e8\u89c1\u5c71\u56de\u7b54\uff1a<\/strong><br \/>\u8981\u5c06\u5b57\u7b26\u6570\u7ec4\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528 String \u6784\u9020\u51fd\u6570\u6216 StringBuilder \u7c7b\u3002<\/p>\n<p><strong>\u8be6\u7ec6\u8bf4\u660e\uff1a<\/strong><\/p>\n<p><strong>\u65b9\u6cd5 1\uff1a\u4f7f\u7528 String \u6784\u9020\u51fd\u6570<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>char[] charArray = {'H', 'e', 'l', 'l', 'o'};\nString str = new String(charArray);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u65b9\u6cd5 2\uff1a\u4f7f\u7528 StringBuilder \u7c7b<\/strong><\/p>\n<pre>char[] charArray = {'H', 'e', 'l', 'l', 'o'};\nStringBuilder sb = new StringBuilder();\nsb.append(charArray);\nString str = sb.toString();<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u9009\u62e9\u65b9\u6cd5\uff1a<\/strong><\/p>\n<ul>\n<li>\u5982\u679c\u5b57\u7b26\u6570\u7ec4\u662f\u4e0d\u53ef\u53d8\u7684\uff0c\u5219\u4f7f\u7528 String \u6784\u9020\u51fd\u6570\u53ef\u4ee5\u521b\u5efa\u65b0\u5b57\u7b26\u4e32\uff0c\u907f\u514d\u5bf9\u539f\u59cb\u6570\u7ec4\u8fdb\u884c\u4fee\u6539\u3002<\/li>\n<li>\u5982\u679c\u5b57\u7b26\u6570\u7ec4\u662f\u53ef\u53d8\u7684\u6216\u9700\u8981\u4fee\u6539\u5b57\u7b26\u4e32\uff0c\u5219\u4f7f\u7528 StringBuilder \u7c7b\u53ef\u4ee5\u63d0\u9ad8\u6548\u7387\uff0c\u56e0\u4e3a\u5b83\u4e0d\u4f1a\u521b\u5efa\u65b0\u5b57\u7b26\u4e32\uff0c\u800c\u662f\u4fee\u6539\u73b0\u6709\u5b57\u7b26\u4e32\u3002<\/li>\n<\/ul>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<ul>\n<li>\u5b57\u7b26\u6570\u7ec4\u5fc5\u987b\u5305\u542b\u6709\u6548\u7684 Unicode \u5b57\u7b26\u3002<\/li>\n<li>\u5982\u679c\u5b57\u7b26\u6570\u7ec4\u5305\u542b Unicode \u4ee3\u7406\uff08\u4ee3\u7406\u5bf9\uff09\uff0c\u9700\u8981\u5728\u6784\u9020 String \u6216 StringBuilder \u65f6\u4f7f\u7528\u9002\u5f53\u7684\u7f16\u7801\u53c2\u6570\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u5b57\u7b26\u6570\u7ec4\u600e\u4e48\u53d8\u6210\u5b57\u7b26\u4e32\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>\u8981\u5c06\u5b57\u7b26\u6570\u7ec4\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528 string \u6784\u9020\u51fd\u6570\u6216 stringbuilder \u7c7b\u3002 string \u6784\u9020\u51fd\u6570\u9002\u5408\u5904\u7406\u4e0d\u53ef\u53d8\u5b57\u7b26\u6570\u7ec4\uff0c\u800c stringbuilder \u7c7b\u66f4\u9002\u5408\u5904\u7406\u53ef\u53d8\u5b57\u7b26\u6570\u7ec4\u6216\u9700\u8981\u4fee\u6539\u5b57\u7b26\u4e32\u7684\u60c5\u51b5\u3002 \u5982\u4f55\u5728 Java \u4e2d\u5c06\u5b57\u7b26\u6570\u7ec4\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32 \u5f00\u95e8\u89c1\u5c71\u56de\u7b54\uff1a\u8981\u5c06\u5b57\u7b26\u6570\u7ec4\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528 String \u6784\u9020\u51fd\u6570\u6216 StringBuilder \u7c7b\u3002 \u8be6\u7ec6\u8bf4\u660e\uff1a \u65b9\u6cd5 1\uff1a\u4f7f\u7528 String \u6784\u9020\u51fd\u6570 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b char[] charArray = {&#8216;H&#8217;, &#8216;e&#8217;, &#8216;l&#8217;, &#8216;l&#8217;, &#8216;o&#8217;}; String str = new String(charArray); \u767b\u5f55\u540e\u590d\u5236 \u65b9\u6cd5 2\uff1a\u4f7f\u7528 StringBuilder \u7c7b char[] charArray = {&#8216;H&#8217;, &#8216;e&#8217;, &#8216;l&#8217;, &#8216;l&#8217;, &#8216;o&#8217;}; StringBuilder sb = new StringBuilder(); sb.append(charArray); [&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-38580","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/38580","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=38580"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/38580\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=38580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=38580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=38580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}