{"id":2204,"date":"2025-03-02T10:26:58","date_gmt":"2025-03-02T02:26:58","guid":{"rendered":"https:\/\/www.laixuexila.com\/?p=2204"},"modified":"2025-03-02T10:26:58","modified_gmt":"2025-03-02T02:26:58","slug":"java-character-%e7%b1%bb","status":"publish","type":"post","link":"https:\/\/www.laixuexila.com\/index.php\/2025\/03\/02\/java-character-%e7%b1%bb\/","title":{"rendered":"Java Character \u7c7b"},"content":{"rendered":"\n<p><code>Character<\/code> \u7c7b\u662f Java \u4e2d\u7528\u6765\u5904\u7406\u5355\u4e2a\u5b57\u7b26\u7684\u7c7b\u3002\u5b83\u662f <code>java.lang<\/code> \u5305\u7684\u4e00\u90e8\u5206\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e9b\u6709\u7528\u7684\u65b9\u6cd5\u6765\u64cd\u4f5c\u548c\u68c0\u67e5\u5b57\u7b26\u3002<code>Character<\/code> \u7c7b\u5c01\u88c5\u4e86\u57fa\u672c\u6570\u636e\u7c7b\u578b <code>char<\/code>\uff0c\u5e76\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5e38\u7528\u7684\u5b57\u7b26\u64cd\u4f5c\u529f\u80fd\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. <code>Character<\/code> \u7c7b\u6982\u8ff0<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Character<\/code> \u662f\u4e00\u4e2a\u5305\u88c5\u7c7b\uff0c\u5c01\u88c5\u4e86\u57fa\u672c\u6570\u636e\u7c7b\u578b <code>char<\/code>\u3002<\/li>\n\n\n\n<li>\u5b83\u63d0\u4f9b\u4e86\u8bb8\u591a\u9759\u6001\u65b9\u6cd5\u6765\u64cd\u4f5c\u5b57\u7b26\uff0c\u4f8b\u5982\u5224\u65ad\u5b57\u7b26\u662f\u5426\u4e3a\u5b57\u6bcd\u3001\u6570\u5b57\u3001\u7a7a\u767d\u5b57\u7b26\u7b49\u3002<\/li>\n\n\n\n<li><code>Character<\/code> \u7c7b\u8fd8\u63d0\u4f9b\u4e86\u5c06\u5b57\u7b26\u8f6c\u5316\u4e3a\u5bf9\u5e94\u7684\u5b57\u7b26\u3001\u5927\u5c0f\u5199\u8f6c\u6362\u3001\u5b57\u7b26\u7f16\u7801\u7b49\u529f\u80fd\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. \u5e38\u7528\u65b9\u6cd5<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">2.1 <code>isLetter(char ch)<\/code>\uff1a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5224\u65ad\u4e00\u4e2a\u5b57\u7b26\u662f\u5426\u4e3a\u5b57\u6bcd\u3002<\/li>\n\n\n\n<li>\u8fd4\u56de <code>true<\/code> \u5982\u679c\u5b57\u7b26\u662f\u5b57\u6bcd\uff0c\u5426\u5219\u8fd4\u56de <code>false<\/code>\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2.2 <code>isDigit(char ch)<\/code>\uff1a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5224\u65ad\u4e00\u4e2a\u5b57\u7b26\u662f\u5426\u4e3a\u6570\u5b57\u3002<\/li>\n\n\n\n<li>\u8fd4\u56de <code>true<\/code> \u5982\u679c\u5b57\u7b26\u662f\u6570\u5b57\uff0c\u5426\u5219\u8fd4\u56de <code>false<\/code>\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2.3 <code>isWhitespace(char ch)<\/code>\uff1a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5224\u65ad\u4e00\u4e2a\u5b57\u7b26\u662f\u5426\u4e3a\u7a7a\u683c\u3001\u6362\u884c\u7b26\u3001\u5236\u8868\u7b26\u7b49\u7a7a\u767d\u5b57\u7b26\u3002<\/li>\n\n\n\n<li>\u8fd4\u56de <code>true<\/code> \u5982\u679c\u662f\u7a7a\u767d\u5b57\u7b26\uff0c\u5426\u5219\u8fd4\u56de <code>false<\/code>\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2.4 <code>isUpperCase(char ch)<\/code>\uff1a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5224\u65ad\u4e00\u4e2a\u5b57\u7b26\u662f\u5426\u662f\u5927\u5199\u5b57\u6bcd\u3002<\/li>\n\n\n\n<li>\u8fd4\u56de <code>true<\/code> \u5982\u679c\u662f\u5927\u5199\u5b57\u6bcd\uff0c\u5426\u5219\u8fd4\u56de <code>false<\/code>\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2.5 <code>isLowerCase(char ch)<\/code>\uff1a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5224\u65ad\u4e00\u4e2a\u5b57\u7b26\u662f\u5426\u662f\u5c0f\u5199\u5b57\u6bcd\u3002<\/li>\n\n\n\n<li>\u8fd4\u56de <code>true<\/code> \u5982\u679c\u662f\u5c0f\u5199\u5b57\u6bcd\uff0c\u5426\u5219\u8fd4\u56de <code>false<\/code>\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2.6 <code>toUpperCase(char ch)<\/code>\uff1a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5c06\u5b57\u7b26\u8f6c\u6362\u4e3a\u5927\u5199\u5b57\u6bcd\u3002<\/li>\n\n\n\n<li>\u8fd4\u56de\u5bf9\u5e94\u7684\u5927\u5199\u5b57\u6bcd\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2.7 <code>toLowerCase(char ch)<\/code>\uff1a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5c06\u5b57\u7b26\u8f6c\u6362\u4e3a\u5c0f\u5199\u5b57\u6bcd\u3002<\/li>\n\n\n\n<li>\u8fd4\u56de\u5bf9\u5e94\u7684\u5c0f\u5199\u5b57\u6bcd\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2.8 <code>toString(char ch)<\/code>\uff1a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5c06\u5b57\u7b26\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u3002<\/li>\n\n\n\n<li>\u8fd4\u56de\u5305\u542b\u8be5\u5b57\u7b26\u7684\u5b57\u7b26\u4e32\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2.9 <code>charValue()<\/code>\uff1a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8fd4\u56de\u8be5\u5b57\u7b26\u5bf9\u8c61\u7684 <code>char<\/code> \u503c\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2.10 <code>forDigit(int digit, int radix)<\/code>\uff1a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8fd4\u56de\u8868\u793a\u7ed9\u5b9a\u6570\u5b57\u7684\u5b57\u7b26\uff08\u5982\u6570\u5b57\u8f6c\u6362\u4e3a\u5b57\u7b26\uff09\u3002<\/li>\n\n\n\n<li><code>digit<\/code> \u662f\u6570\u5b57\uff0c<code>radix<\/code> \u662f\u8fdb\u5236\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. <code>Character<\/code> \u7c7b\u7684\u5e38\u89c1\u7528\u6cd5\u5b9e\u4f8b<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">3.1 \u5224\u65ad\u5b57\u7b26\u662f\u5426\u4e3a\u5b57\u6bcd\u6216\u6570\u5b57<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>public class CharacterExample {\n    public static void main(String&#91;] args) {\n        char c1 = 'A';\n        char c2 = '3';\n        char c3 = '#';\n\n        System.out.println(\"Is 'A' a letter? \" + Character.isLetter(c1));  \/\/ true\n        System.out.println(\"Is '3' a digit? \" + Character.isDigit(c2));    \/\/ true\n        System.out.println(\"Is '#' a letter? \" + Character.isLetter(c3));  \/\/ false\n        System.out.println(\"Is '3' a whitespace? \" + Character.isWhitespace(c2));  \/\/ false\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong>\u8f93\u51fa\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Is 'A' a letter? true\nIs '3' a digit? true\nIs '#' a letter? false\nIs '3' a whitespace? false<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">3.2 \u5224\u65ad\u5b57\u7b26\u7684\u5927\u5c0f\u5199<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>public class CharacterCaseExample {\n    public static void main(String&#91;] args) {\n        char upper = 'Z';\n        char lower = 'z';\n\n        System.out.println(\"Is 'Z' uppercase? \" + Character.isUpperCase(upper));  \/\/ true\n        System.out.println(\"Is 'z' lowercase? \" + Character.isLowerCase(lower));  \/\/ true\n\n        \/\/ \u8f6c\u6362\u5927\u5c0f\u5199\n        System.out.println(\"Lowercase of 'Z': \" + Character.toLowerCase(upper));  \/\/ z\n        System.out.println(\"Uppercase of 'z': \" + Character.toUpperCase(lower));  \/\/ Z\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong>\u8f93\u51fa\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Is 'Z' uppercase? true\nIs 'z' lowercase? true\nLowercase of 'Z': z\nUppercase of 'z': Z<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">3.3 \u5224\u65ad\u7a7a\u767d\u5b57\u7b26<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>public class CharacterWhitespaceExample {\n    public static void main(String&#91;] args) {\n        char space = ' ';\n        char tab = '\\t';\n        char newLine = '\\n';\n        char letter = 'A';\n\n        System.out.println(\"Is space a whitespace? \" + Character.isWhitespace(space));  \/\/ true\n        System.out.println(\"Is tab a whitespace? \" + Character.isWhitespace(tab));  \/\/ true\n        System.out.println(\"Is newLine a whitespace? \" + Character.isWhitespace(newLine));  \/\/ true\n        System.out.println(\"Is 'A' a whitespace? \" + Character.isWhitespace(letter));  \/\/ false\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong>\u8f93\u51fa\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Is space a whitespace? true\nIs tab a whitespace? true\nIs newLine a whitespace? true\nIs 'A' a whitespace? false<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">3.4 \u5c06\u5b57\u7b26\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>public class CharacterToStringExample {\n    public static void main(String&#91;] args) {\n        char c = 'A';\n        String str = Character.toString(c);  \/\/ \u5c06\u5b57\u7b26\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\n        System.out.println(\"Character as String: \" + str);  \/\/ \u8f93\u51fa \"A\"\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong>\u8f93\u51fa\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Character as String: A<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">3.5 <code>forDigit()<\/code> \u65b9\u6cd5\uff1a\u5c06\u6570\u5b57\u8f6c\u6362\u4e3a\u5b57\u7b26<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>public class CharacterForDigitExample {\n    public static void main(String&#91;] args) {\n        int digit = 9;\n        int radix = 10;\n        char c = Character.forDigit(digit, radix);  \/\/ \u5c06\u6570\u5b57 9 \u8f6c\u6362\u4e3a\u5b57\u7b26 '9'\n        System.out.println(\"Character for digit 9 in radix 10: \" + c);  \/\/ \u8f93\u51fa '9'\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong>\u8f93\u51fa\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Character for digit 9 in radix 10: 9<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. \u603b\u7ed3<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Character<\/code> \u7c7b\u662f\u7528\u4e8e\u64cd\u4f5c\u5355\u4e2a\u5b57\u7b26\u7684\u5de5\u5177\u7c7b\u3002<\/li>\n\n\n\n<li>\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u65b9\u6cd5\u6765\u68c0\u67e5\u5b57\u7b26\u7684\u7c7b\u578b\uff08\u5982\u5b57\u6bcd\u3001\u6570\u5b57\u3001\u7a7a\u767d\u5b57\u7b26\uff09\u3001\u8fdb\u884c\u5927\u5c0f\u5199\u8f6c\u6362\u3001\u5b57\u7b26\u5230\u5b57\u7b26\u4e32\u7684\u8f6c\u6362\u7b49\u3002<\/li>\n\n\n\n<li><code>Character<\/code> \u7c7b\u4e2d\u7684\u65b9\u6cd5\u662f\u9759\u6001\u7684\uff0c\u56e0\u6b64\u65e0\u9700\u521b\u5efa <code>Character<\/code> \u5bf9\u8c61\uff0c\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7\u7c7b\u540d\u8c03\u7528\u3002<\/li>\n\n\n\n<li>\u5e38\u7528\u7684\u529f\u80fd\u5305\u62ec\u5b57\u7b26\u5224\u65ad\uff08\u5982\u662f\u5426\u4e3a\u5b57\u6bcd\u3001\u6570\u5b57\u7b49\uff09\u3001\u5927\u5c0f\u5199\u8f6c\u6362\u3001\u5b57\u7b26\u8f6c\u5316\u4e3a\u5b57\u7b26\u4e32\u3001\u5b57\u7b26\u5230\u6570\u5b57\u7684\u8f6c\u6362\u7b49\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u5e0c\u671b\u8fd9\u4e2a\u8be6\u7ec6\u4ecb\u7ecd\u80fd\u5e2e\u52a9\u4f60\u7406\u89e3 <code>Character<\/code> \u7c7b\u3002\u66f4\u591a\u8be6\u7ec6\u5185\u5bb9\u8bf7\u5173\u6ce8\u5176\u4ed6\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Character \u7c7b\u662f Java \u4e2d\u7528\u6765\u5904\u7406\u5355\u4e2a\u5b57\u7b26\u7684\u7c7b\u3002\u5b83\u662f java.lang \u5305\u7684\u4e00\u90e8\u5206\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e9b\u6709 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[68],"tags":[],"class_list":["post-2204","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/2204","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/comments?post=2204"}],"version-history":[{"count":1,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/2204\/revisions"}],"predecessor-version":[{"id":2205,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/2204\/revisions\/2205"}],"wp:attachment":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media?parent=2204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/categories?post=2204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/tags?post=2204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}