{"id":66606,"date":"2025-05-03T13:57:47","date_gmt":"2025-05-03T05:57:47","guid":{"rendered":"https:\/\/fwq.ai\/blog\/66606\/"},"modified":"2025-05-03T13:57:47","modified_gmt":"2025-05-03T05:57:47","slug":"%e6%80%8e%e4%b9%88%e6%8a%8a%e5%b0%8f%e5%86%99%e6%94%b9%e6%88%90%e5%a4%a7%e5%86%99java%e6%95%b0%e7%bb%84-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/66606\/","title":{"rendered":"\u600e\u4e48\u628a\u5c0f\u5199\u6539\u6210\u5927\u5199java\u6570\u7ec4"},"content":{"rendered":"<blockquote><p>\n  \u6709\u4e09\u79cd\u65b9\u6cd5\u53ef\u4ee5\u5c06 java \u6570\u7ec4\u4e2d\u7684\u5c0f\u5199\u5b57\u7b26\u66f4\u6539\u4e3a\u5927\u5199\u5b57\u7b26\uff1a\u76f4\u63a5\u65b9\u6cd5\uff1a\u4f7f\u7528 apache commons lang3 \u5e93\u7684 stringutils.uppercase() \u65b9\u6cd5\u3002\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\uff1a\u4f7f\u7528 string.replaceall() \u65b9\u6cd5\u66ff\u6362\u5c0f\u5199\u5b57\u7b26\u3002\u624b\u52a8\u8f6c\u6362\uff1a\u904d\u5386\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\uff0c\u5982\u679c\u5b57\u7b26\u662f\u5c0f\u5199\u5b57\u7b26\uff0c\u5219\u5c06\u5176\u66ff\u6362\u4e3a\u5927\u5199\u5b57\u7b26\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/16\/2024111610075472609.jpg\" class=\"aligncenter\" title=\"\u600e\u4e48\u628a\u5c0f\u5199\u6539\u6210\u5927\u5199java\u6570\u7ec4\u63d2\u56fe\" alt=\"\u600e\u4e48\u628a\u5c0f\u5199\u6539\u6210\u5927\u5199java\u6570\u7ec4\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5c06 Java \u6570\u7ec4\u4e2d\u7684\u5c0f\u5199\u5b57\u7b26\u66f4\u6539\u4e3a\u5927\u5199\u5b57\u7b26<\/strong><\/p>\n<p><strong>\u76f4\u63a5\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528 Apache Commons Lang3 \u5e93\u7684 StringUtils.upperCase() \u65b9\u6cd5\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>import org.apache.commons.lang3.StringUtils;\n\nString[] names = {\"john\", \"mary\", \"bob\"};\n\nfor (int i = 0; i &lt; names.length; i++) {\n    names[i] = StringUtils.upperCase(names[i]);\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u4f7f\u7528 String.replaceAll() \u65b9\u6cd5\u66ff\u6362\u5c0f\u5199\u5b57\u7b26\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>String[] names = {\"john\", \"mary\", \"bob\"};\n\nfor (int i = 0; i &lt; names.length; i++) {\n    names[i] = names[i].replaceAll(\"[a-z]\", names[i].toUpperCase());\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u624b\u52a8\u8f6c\u6362\uff1a<\/strong><\/p>\n<p>\u904d\u5386\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\uff0c\u5982\u679c\u5b57\u7b26\u662f\u5c0f\u5199\u5b57\u7b26\uff0c\u5219\u5c06\u5176\u66ff\u6362\u4e3a\u5927\u5199\u5b57\u7b26\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>String[] names = {\"john\", \"mary\", \"bob\"};\n\nfor (int i = 0; i &lt; names.length; i++) {\n    StringBuilder sb = new StringBuilder();\n    for (char c : names[i].toCharArray()) {\n        if (Character.isLowerCase(c)) {\n            sb.append(Character.toUpperCase(c));\n        } else {\n            sb.append(c);\n        }\n    }\n    names[i] = sb.toString();\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u628a\u5c0f\u5199\u6539\u6210\u5927\u5199java\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>\u6709\u4e09\u79cd\u65b9\u6cd5\u53ef\u4ee5\u5c06 java \u6570\u7ec4\u4e2d\u7684\u5c0f\u5199\u5b57\u7b26\u66f4\u6539\u4e3a\u5927\u5199\u5b57\u7b26\uff1a\u76f4\u63a5\u65b9\u6cd5\uff1a\u4f7f\u7528 apache commons lang3 \u5e93\u7684 stringutils.uppercase() \u65b9\u6cd5\u3002\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\uff1a\u4f7f\u7528 string.replaceall() \u65b9\u6cd5\u66ff\u6362\u5c0f\u5199\u5b57\u7b26\u3002\u624b\u52a8\u8f6c\u6362\uff1a\u904d\u5386\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\uff0c\u5982\u679c\u5b57\u7b26\u662f\u5c0f\u5199\u5b57\u7b26\uff0c\u5219\u5c06\u5176\u66ff\u6362\u4e3a\u5927\u5199\u5b57\u7b26\u3002 \u5982\u4f55\u5c06 Java \u6570\u7ec4\u4e2d\u7684\u5c0f\u5199\u5b57\u7b26\u66f4\u6539\u4e3a\u5927\u5199\u5b57\u7b26 \u76f4\u63a5\u65b9\u6cd5\uff1a \u4f7f\u7528 Apache Commons Lang3 \u5e93\u7684 StringUtils.upperCase() \u65b9\u6cd5\uff0c\u5982\u4e0b\u6240\u793a\uff1a import org.apache.commons.lang3.StringUtils; String[] names = {&#8220;john&#8221;, &#8220;mary&#8221;, &#8220;bob&#8221;}; for (int i = 0; i &lt; names.length; i++) { names[i] = StringUtils.upperCase(names[i]); } \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4f7f\u7528 String.replaceAll() \u65b9\u6cd5\u66ff\u6362\u5c0f\u5199\u5b57\u7b26\uff0c\u5982\u4e0b\u6240\u793a\uff1a String[] names = {&#8220;john&#8221;, &#8220;mary&#8221;, [&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-66606","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66606","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=66606"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66606\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=66606"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=66606"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=66606"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}