Java : Character 示例

Character (Java SE 22 & JDK 22) 示例。
您将在大多数 Character 方法中找到代码示例。

注解 :

  • 本文可能使用了翻译软件以方便阅读。 另请查看英文原文

简介

Character 类将原始类型 char 的值包装在对象中。Character 类的对象包含一个类型为 char 的字段。 (机器翻译)

Class diagram

// Compile error.
final var list = new ArrayList<char>();
// OK.
final var list = new ArrayList<Character>();
list.add('a');
list.add('b');
list.add('c');

System.out.println(list); // [a, b, c]
System.out.println(Character.isDigit('1')); // true
System.out.println(Character.isDigit('2')); // true
System.out.println(Character.isDigit('Z')); // false

System.out.println(Character.toUpperCase('a')); // A
System.out.println(Character.toUpperCase('b')); // B
System.out.println(Character.toUpperCase('c')); // C

Fields

static final int BYTES

用来以无符号二进制形式表示 char 值的字节数。 (机器翻译)

System.out.println(Character.BYTES); // 2

static final byte COMBINING_SPACING_MARK

Unicode 规范中的通用类别“Mc”。 (机器翻译)

System.out.println(Character.COMBINING_SPACING_MARK); // 8

System.out.println(Character.getType('ः')); // 8
System.out.println(Character.getType('ᤣ')); // 8

static final byte CONNECTOR_PUNCTUATION

Unicode 规范中的通用类别“Pc”。 (机器翻译)

System.out.println(Character.CONNECTOR_PUNCTUATION); // 23

System.out.println(Character.getType('_')); // 23
System.out.println(Character.getType('﹏')); // 23

static final byte CONTROL

Unicode 规范中的通用类别“Cc”。 (机器翻译)

System.out.println(Character.CONTROL); // 15

System.out.println(Character.getType('\u0000')); // 15
System.out.println(Character.getType('\u001b')); // 15

static final byte CURRENCY_SYMBOL

Unicode 规范中的通用类别“Sc”。 (机器翻译)

System.out.println(Character.CURRENCY_SYMBOL); // 26

System.out.println(Character.getType('$')); // 26
System.out.println(Character.getType('¥')); // 26

static final byte DASH_PUNCTUATION

Unicode 规范中的通用类别“Pd”。 (机器翻译)

System.out.println(Character.DASH_PUNCTUATION); // 20

System.out.println(Character.getType('-')); // 20
System.out.println(Character.getType('〜')); // 20

static final byte DECIMAL_DIGIT_NUMBER

Unicode 规范中的通用类别“Nd”。 (机器翻译)

System.out.println(Character.DECIMAL_DIGIT_NUMBER); // 9

System.out.println(Character.getType('1')); // 9
System.out.println(Character.getType('2')); // 9

static final byte DIRECTIONALITY_ARABIC_NUMBER

Unicode 规范中的弱双向字符类型“AN”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_ARABIC_NUMBER); // 6

System.out.println(Character.getDirectionality('٠')); // 6
System.out.println(Character.getDirectionality('٢')); // 6

static final byte DIRECTIONALITY_BOUNDARY_NEUTRAL

Unicode 规范中的弱双向字符类型“BN”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_BOUNDARY_NEUTRAL); // 9

System.out.println(Character.getDirectionality('\u0000')); // 9
System.out.println(Character.getDirectionality('\u001b')); // 9

static final byte DIRECTIONALITY_COMMON_NUMBER_SEPARATOR

Unicode 规范中的弱双向字符类型“CS”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_COMMON_NUMBER_SEPARATOR); // 7

System.out.println(Character.getDirectionality(',')); // 7
System.out.println(Character.getDirectionality(':')); // 7

static final byte DIRECTIONALITY_EUROPEAN_NUMBER

Unicode 规范中的弱双向字符类型“EN”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_EUROPEAN_NUMBER); // 3

System.out.println(Character.getDirectionality('1')); // 3
System.out.println(Character.getDirectionality('2')); // 3

static final byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR

Unicode 规范中的弱双向字符类型“ES”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR); // 4

System.out.println(Character.getDirectionality('+')); // 4
System.out.println(Character.getDirectionality('-')); // 4

static final byte DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR

Unicode 规范中的弱双向字符类型“ET”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR); // 5

System.out.println(Character.getDirectionality('#')); // 5
System.out.println(Character.getDirectionality('$')); // 5

static final byte DIRECTIONALITY_FIRST_STRONG_ISOLATE

Unicode 规范中的弱双向字符类型“FSI”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_FIRST_STRONG_ISOLATE); // 21

System.out.println(Character.getDirectionality('\u2068')); // 21

static final byte DIRECTIONALITY_LEFT_TO_RIGHT

Unicode 规范中的强双向字符类型“L”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_LEFT_TO_RIGHT); // 0

System.out.println(Character.getDirectionality('A')); // 0
System.out.println(Character.getDirectionality('B')); // 0

static final byte DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING

Unicode 规范中的强双向字符类型“LRE”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING); // 14

System.out.println(Character.getDirectionality('\u202a')); // 14

static final byte DIRECTIONALITY_LEFT_TO_RIGHT_ISOLATE

Unicode 规范中的弱双向字符类型“LRI”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_LEFT_TO_RIGHT_ISOLATE); // 19

System.out.println(Character.getDirectionality('\u2066')); // 19

static final byte DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE

Unicode 规范中的强双向字符类型“LRO”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE); // 15

System.out.println(Character.getDirectionality('\u202d')); // 15

static final byte DIRECTIONALITY_NONSPACING_MARK

Unicode 规范中的弱双向字符类型“NSM”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_NONSPACING_MARK); // 8

System.out.println(Character.getDirectionality('̀')); // 8
System.out.println(Character.getDirectionality('̃')); // 8

static final byte DIRECTIONALITY_OTHER_NEUTRALS

Unicode 规范中的中性双向字符类型“ON”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_OTHER_NEUTRALS); // 13

System.out.println(Character.getDirectionality('!')); // 13
System.out.println(Character.getDirectionality('&')); // 13

static final byte DIRECTIONALITY_PARAGRAPH_SEPARATOR

Unicode 规范中的中性双向字符类型“B”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_PARAGRAPH_SEPARATOR); // 10

System.out.println(Character.getDirectionality('\n')); // 10
System.out.println(Character.getDirectionality('\r')); // 10

static final byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT

Unicode 规范中的弱双向字符类型“PDF”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_POP_DIRECTIONAL_FORMAT); // 18

System.out.println(Character.getDirectionality('\u202c')); // 18

static final byte DIRECTIONALITY_POP_DIRECTIONAL_ISOLATE

Unicode 规范中的弱双向字符类型“PDI”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_POP_DIRECTIONAL_ISOLATE); // 22

System.out.println(Character.getDirectionality('\u2069')); // 22

static final byte DIRECTIONALITY_RIGHT_TO_LEFT

Unicode 规范中的强双向字符类型“R”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_RIGHT_TO_LEFT); // 1

System.out.println(Character.getDirectionality('א')); // 1
System.out.println(Character.getDirectionality('ט')); // 1

static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC

Unicode 规范中的强双向字符类型“AL”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC); // 2

System.out.println(Character.getDirectionality('؈')); // 2
System.out.println(Character.getDirectionality('ب')); // 2

static final byte DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING

Unicode 规范中的强双向字符类型“RLE”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING); // 16

System.out.println(Character.getDirectionality('\u202b')); // 16

static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ISOLATE

Unicode 规范中的弱双向字符类型“RLI”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_RIGHT_TO_LEFT_ISOLATE); // 20

System.out.println(Character.getDirectionality('\u2067')); // 20

static final byte DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE

Unicode 规范中的强双向字符类型“RLO”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE); // 17

System.out.println(Character.getDirectionality('\u202e')); // 17

static final byte DIRECTIONALITY_SEGMENT_SEPARATOR

Unicode 规范中的中性双向字符类型“S”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_SEGMENT_SEPARATOR); // 11

System.out.println(Character.getDirectionality('\t')); // 11

static final byte DIRECTIONALITY_UNDEFINED

未定义双向字符类型。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_UNDEFINED); // -1

System.out.println(Character.getDirectionality('\uFFFF')); // -1

static final byte DIRECTIONALITY_WHITESPACE

Unicode 规范中的中性双向字符类型“WS”。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_WHITESPACE); // 12

System.out.println(Character.getDirectionality(' ')); // 12

static final byte ENCLOSING_MARK

Unicode 规范中的通用类别“Me”。 (机器翻译)

System.out.println(Character.ENCLOSING_MARK); // 7

System.out.println(Character.getType('⃣')); // 7
System.out.println(Character.getType('⃠')); // 7

static final byte END_PUNCTUATION

Unicode 规范中的通用类别“Pe”。 (机器翻译)

System.out.println(Character.END_PUNCTUATION); // 22

System.out.println(Character.getType(')')); // 22
System.out.println(Character.getType(']')); // 22

static final byte FINAL_QUOTE_PUNCTUATION

Unicode 规范中的通用类别“Pf”。 (机器翻译)

System.out.println(Character.FINAL_QUOTE_PUNCTUATION); // 30

System.out.println(Character.getType('”')); // 30
System.out.println(Character.getType('»')); // 30

static final byte FORMAT

Unicode 规范中的通用类别“Cf”。 (机器翻译)

System.out.println(Character.FORMAT); // 16

System.out.println(Character.getType('\u00ad')); // 16

static final byte INITIAL_QUOTE_PUNCTUATION

Unicode 规范中的通用类别“Pi”。 (机器翻译)

System.out.println(Character.INITIAL_QUOTE_PUNCTUATION); // 29

System.out.println(Character.getType('“')); // 29
System.out.println(Character.getType('«')); // 29

static final byte LETTER_NUMBER

Unicode 规范中的通用类别“Nl”。 (机器翻译)

System.out.println(Character.LETTER_NUMBER); // 10

System.out.println(Character.getType('Ⅱ')); // 10
System.out.println(Character.getType('ᛯ')); // 10

static final byte LINE_SEPARATOR

Unicode 规范中的通用类别“Zl”。 (机器翻译)

System.out.println(Character.LINE_SEPARATOR); // 13

System.out.println(Character.getType('\u2028')); // 13

static final byte LOWERCASE_LETTER

Unicode 规范中的通用类别“Ll”。 (机器翻译)

System.out.println(Character.LOWERCASE_LETTER); // 2

System.out.println(Character.getType('a')); // 2
System.out.println(Character.getType('ē')); // 2

static final byte MATH_SYMBOL

Unicode 规范中的通用类别“Sm”。 (机器翻译)

System.out.println(Character.MATH_SYMBOL); // 25

System.out.println(Character.getType('+')); // 25
System.out.println(Character.getType('=')); // 25

static final int MAX_CODE_POINT

Unicode 代码点的最大值,常数 U+10FFFF。 (机器翻译)

System.out.printf("%x%n", Character.MAX_CODE_POINT); // 10ffff

static final char MAX_HIGH_SURROGATE

UTF-16 编码中 Unicode 高代理代码单元的最大值,常数“\uDBFF”。 (机器翻译)

System.out.println(Integer.toHexString(Character.MAX_HIGH_SURROGATE)); // dbff

static final char MAX_LOW_SURROGATE

UTF-16 编码中 Unicode 低代理代码单元的最大值,常数“\uDFFF”。 (机器翻译)

System.out.println(Integer.toHexString(Character.MAX_LOW_SURROGATE)); // dfff

static final int MAX_RADIX

可用于与字符串相互转换的最大基数。 (机器翻译)

System.out.println(Character.MAX_RADIX); // 36

static final char MAX_SURROGATE

UTF-16 编码中 Unicode 代理代码单元的最大值,常数“\uDFFF”。 (机器翻译)

System.out.println(Integer.toHexString(Character.MAX_SURROGATE)); // dfff

static final char MAX_VALUE

该字段的常量值是char类型的最大值'\uFFFF'。 (机器翻译)

System.out.println(Integer.toHexString(Character.MAX_VALUE)); // ffff

static final int MIN_CODE_POINT

Unicode 代码点的最小值,常数 U+0000。 (机器翻译)

System.out.println(Integer.toHexString(Character.MIN_CODE_POINT)); // 0

static final char MIN_HIGH_SURROGATE

UTF-16 编码中 Unicode 高代理代码单元的最小值,常数“\uD800”。 (机器翻译)

System.out.println(Integer.toHexString(Character.MIN_HIGH_SURROGATE)); // d800

static final char MIN_LOW_SURROGATE

UTF-16 编码中 Unicode 低代理代码单元的最小值,常数“\uDC00”。 (机器翻译)

System.out.println(Integer.toHexString(Character.MIN_LOW_SURROGATE)); // dc00

static final int MIN_RADIX

可用于与字符串相互转换的最小基数。 (机器翻译)

System.out.println(Character.MIN_RADIX); // 2

static final int MIN_SUPPLEMENTARY_CODE_POINT

Unicode 补充代码点的最小值,常数 U+10000。 (机器翻译)

final var value = Character.MIN_SUPPLEMENTARY_CODE_POINT;
System.out.println(Integer.toHexString(value)); // 10000

static final char MIN_SURROGATE

UTF-16 编码中 Unicode 代理代码单元的最小值,常数“\uD800”。 (机器翻译)

System.out.println(Integer.toHexString(Character.MIN_SURROGATE)); // d800

static final char MIN_VALUE

该字段的常量值是char类型的最小值'\u0000'。 (机器翻译)

System.out.println(Integer.toHexString(Character.MIN_VALUE)); // 0

static final byte MODIFIER_LETTER

Unicode 规范中的通用类别“Lm”。 (机器翻译)

System.out.println(Character.MODIFIER_LETTER); // 4

System.out.println(Character.getType('ʰ')); // 4
System.out.println(Character.getType('ʺ')); // 4

static final byte MODIFIER_SYMBOL

Unicode 规范中的通用类别“Sk”。 (机器翻译)

System.out.println(Character.MODIFIER_SYMBOL); // 27

System.out.println(Character.getType('^')); // 27
System.out.println(Character.getType('`')); // 27

static final byte NON_SPACING_MARK

Unicode 规范中的通用类别“Mn”。 (机器翻译)

System.out.println(Character.NON_SPACING_MARK); // 6

System.out.println(Character.getType('̈')); // 6
System.out.println(Character.getType('̆')); // 6

static final byte OTHER_LETTER

Unicode 规范中的通用类别“Lo”。 (机器翻译)

System.out.println(Character.OTHER_LETTER); // 5

System.out.println(Character.getType('ª')); // 5
System.out.println(Character.getType('ƻ')); // 5

static final byte OTHER_NUMBER

Unicode 规范中的一般类别为“否”。 (机器翻译)

System.out.println(Character.OTHER_NUMBER); // 11

System.out.println(Character.getType('¼')); // 11
System.out.println(Character.getType('①')); // 11

static final byte OTHER_PUNCTUATION

Unicode 规范中的通用类别“Po”。 (机器翻译)

System.out.println(Character.OTHER_PUNCTUATION); // 24

System.out.println(Character.getType('!')); // 24
System.out.println(Character.getType('#')); // 24

static final byte OTHER_SYMBOL

Unicode 规范中的通用类别“So”。 (机器翻译)

System.out.println(Character.OTHER_SYMBOL); // 28

System.out.println(Character.getType('¦')); // 28
System.out.println(Character.getType('҂')); // 28

static final byte PARAGRAPH_SEPARATOR

Unicode 规范中的通用类别“Zp”。 (机器翻译)

System.out.println(Character.PARAGRAPH_SEPARATOR); // 14

System.out.println(Character.getType('\u2029')); // 14

static final byte PRIVATE_USE

Unicode 规范中的通用类别“Co”。 (机器翻译)

System.out.println(Character.PRIVATE_USE); // 18

System.out.println(Character.getType('\ue000')); // 18

static final int SIZE

以无符号二进制形式表示字符值的位数,常数 16。 (机器翻译)

System.out.println(Character.SIZE); // 16

static final byte SPACE_SEPARATOR

Unicode 规范中的通用类别“Zs”。 (机器翻译)

System.out.println(Character.SPACE_SEPARATOR); // 12

System.out.println(Character.getType(' ')); // 12

static final byte START_PUNCTUATION

Unicode 规范中的通用类别“Ps”。 (机器翻译)

System.out.println(Character.START_PUNCTUATION); // 21

System.out.println(Character.getType('(')); // 21
System.out.println(Character.getType('[')); // 21

static final byte SURROGATE

Unicode 规范中的通用类别“Cs”。 (机器翻译)

System.out.println(Character.SURROGATE); // 19

System.out.println(Character.getType(Character.MIN_SURROGATE)); // 19
System.out.println(Character.getType(Character.MAX_SURROGATE)); // 19

static final byte TITLECASE_LETTER

Unicode 规范中的通用类别“Lt”。 (机器翻译)

System.out.println(Character.TITLECASE_LETTER); // 3

System.out.println(Character.getType('Dž')); // 3
System.out.println(Character.getType('Lj')); // 3

static final Class<Character> TYPE

表示原始类型 char 的 Class 实例。 (机器翻译)

System.out.println(Character.TYPE.getName()); // char
System.out.println(Character.TYPE.isPrimitive()); // true

static final byte UNASSIGNED

Unicode 规范中的通用类别“Cn”。 (机器翻译)

System.out.println(Character.UNASSIGNED); // 0

System.out.println(Character.getType('\uFFFF')); // 0

static final byte UPPERCASE_LETTER

Unicode 规范中的通用类别“Lu”。 (机器翻译)

System.out.println(Character.UPPERCASE_LETTER); // 1

System.out.println(Character.getType('A')); // 1
System.out.println(Character.getType('Ê')); // 1

Constructors

Character (char value)

已弃用,将删除:此 API 元素将在未来的版本中删除。很少适合使用此构造函数。 (机器翻译)

Deprecated.

Methods

static int charCount (int codePoint)

确定表示指定字符(Unicode 代码点)所需的 char 值的数量。 (机器翻译)

final var ret1 = Character.charCount('a');
System.out.println(ret1); // 1

final var ret2 = Character.charCount('△');
System.out.println(ret2); // 1
final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.println(Character.toString(codePoint)); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

final var ret = Character.charCount(codePoint);
System.out.println(ret); // 2

char charValue ()

返回此 Character 对象的值。 (机器翻译)

final var c = Character.valueOf('a');
System.out.println(c); // a
System.out.println(c.charValue()); // a
final var c = Character.valueOf('△');
System.out.println(c); // △
System.out.println(c.charValue()); // △

static int codePointAt (char[] a, int index)

返回字符数组中给定索引处的代码点。 (机器翻译)

final char[] a = "abc".toCharArray();
System.out.println(Arrays.toString(a)); // [a, b, c]

final var ret1 = Character.codePointAt(a, 0);
System.out.println(Character.toString(ret1)); // a

final var ret2 = Character.codePointAt(a, 1);
System.out.println(Character.toString(ret2)); // b

final var ret3 = Character.codePointAt(a, 2);
System.out.println(Character.toString(ret3)); // c

try {
    Character.codePointAt(a, 3);
} catch (IndexOutOfBoundsException e) {
    System.out.println(e);
}

// Result
// ↓
//java.lang.ArrayIndexOutOfBoundsException: Index 3 out of bounds for length 3
final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.println(Character.toString(codePoint)); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

final var seq = Character.toString(codePoint) + "ab";
System.out.println(seq); // "𝟝ab"

final char[] a = seq.toCharArray();
System.out.println(Arrays.toString(a)); // [?, ?, a, b]

final var ret1 = Character.codePointAt(a, 0);
System.out.printf("%c%n", ret1); // 𝟝

final var ret2 = Character.codePointAt(a, 1);
System.out.printf("%c%n", ret2); // ?
System.out.printf("%x%n", ret2); // dfdd

final var ret3 = Character.codePointAt(a, 2);
System.out.printf("%c%n", ret3); // a

final var ret4 = Character.codePointAt(a, 3);
System.out.printf("%c%n", ret4); // b

static int codePointAt (char[] a, int index, int limit)

返回 char 数组中给定索引处的代码点,其中只有索引小于限制的数组元素才可以使用。 (机器翻译)

Please see also : codePointAt(char[] a, int index)

final char[] a = "abc".toCharArray();
System.out.println(Arrays.toString(a)); // [a, b, c]

final var ret1 = Character.codePointAt(a, 0, 2);
System.out.printf("%c%n", ret1); // a

final var ret2 = Character.codePointAt(a, 1, 2);
System.out.printf("%c%n", ret2); // b

try {
    Character.codePointAt(a, 2, 2);
} catch (IndexOutOfBoundsException e) {
    System.out.println(e);
}

// Result
// ↓
//java.lang.IndexOutOfBoundsException
final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.println(Character.toString(codePoint)); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

final char[] a = Character.toChars(codePoint);
System.out.println(Arrays.toString(a)); // [?, ?]

final var ret1 = Character.codePointAt(a, 0, 2);
System.out.printf("%c%n", ret1); // 𝟝

final var ret2 = Character.codePointAt(a, 1, 2);
System.out.printf("%c%n", ret2); // ?
System.out.printf("%x%n", ret2); // dfdd

final var ret3 = Character.codePointAt(a, 0, 1);
System.out.printf("%c%n", ret3); // ?
System.out.printf("%x%n", ret3); // d835

try {
    Character.codePointAt(a, 1, 1);
} catch (IndexOutOfBoundsException e) {
    System.out.println(e);
}

// Result
// ↓
//java.lang.IndexOutOfBoundsException

static int codePointAt (CharSequence seq, int index)

返回 CharSequence 的给定索引处的代码点。 (机器翻译)

final var seq = "abc";
System.out.println(seq); // abc

final var ret1 = Character.codePointAt(seq, 0);
System.out.printf("%c%n", ret1); // a

final var ret2 = Character.codePointAt(seq, 1);
System.out.printf("%c%n", ret2); // b

final var ret3 = Character.codePointAt(seq, 2);
System.out.printf("%c%n", ret3); // c

try {
    Character.codePointAt(seq, 3);
} catch (IndexOutOfBoundsException e) {
    System.out.println(e);
}

// Result
// ↓
//java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.println(Character.toString(codePoint)); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

final var seq = Character.toString(codePoint) + "ab";
System.out.println(seq); // 𝟝ab

final var ret1 = Character.codePointAt(seq, 0);
System.out.printf("%c%n", ret1); // 𝟝

final var ret2 = Character.codePointAt(seq, 1);
System.out.printf("%c%n", ret2); // ?
System.out.printf("%x%n", ret2); // dfdd

final var ret3 = Character.codePointAt(seq, 2);
System.out.printf("%c%n", ret3); // a

final var ret4 = Character.codePointAt(seq, 3);
System.out.printf("%c%n", ret4); // b

static int codePointBefore (char[] a, int index)

返回字符数组中给定索引前面的代码点。 (机器翻译)

final char[] a = "abc".toCharArray();
System.out.println(Arrays.toString(a)); // [a, b, c]

final var ret1 = Character.codePointBefore(a, 1);
System.out.printf("%c%n", ret1); // a

final var ret2 = Character.codePointBefore(a, 2);
System.out.printf("%c%n", ret2); // b

final var ret3 = Character.codePointBefore(a, 3);
System.out.printf("%c%n", ret3); // c

try {
    Character.codePointBefore(a, 0);
} catch (IndexOutOfBoundsException e) {
    System.out.println(e);
}

// Result
// ↓
//java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 3
final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.println(Character.toString(codePoint)); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

final var seq = Character.toString(codePoint) + "ab";
System.out.println(seq); // 𝟝ab

final char[] a = seq.toCharArray();
System.out.println(Arrays.toString(a)); // [?, ?, a, b]

final var ret1 = Character.codePointBefore(a, 1);
System.out.printf("%c%n", ret1); // ?
System.out.printf("%x%n", ret1); // d835

final var ret2 = Character.codePointBefore(a, 2);
System.out.printf("%c%n", ret2); // 𝟝

final var ret3 = Character.codePointBefore(a, 3);
System.out.printf("%c%n", ret3); // a

final var ret4 = Character.codePointBefore(a, 4);
System.out.printf("%c%n", ret4); // b

static int codePointBefore (char[] a, int index, int start)

返回 char 数组中给定索引前面的代码点,其中只有索引大于或等于 start 的数组元素才可使用。 (机器翻译)

Please see also : codePointBefore(char[] a, int index)

final char[] a = "abc".toCharArray();
System.out.println(Arrays.toString(a)); // [a, b, c]

final var ret1 = Character.codePointBefore(a, 2, 1);
System.out.printf("%c%n", ret1); // b

final var ret2 = Character.codePointBefore(a, 3, 1);
System.out.printf("%c%n", ret2); // c

try {
    Character.codePointBefore(a, 1, 1);
} catch (IndexOutOfBoundsException e) {
    System.out.println(e);
}

// Result
// ↓
//java.lang.IndexOutOfBoundsException
final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.println(Character.toString(codePoint)); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

final var seq = Character.toString(codePoint) + "ab";
System.out.println(seq); // 𝟝ab

final char[] a = seq.toCharArray();
System.out.println(Arrays.toString(a)); // [?, ?, a, b]

final var ret1 = Character.codePointBefore(a, 2, 1);
System.out.printf("%c%n", ret1); // ?
System.out.printf("%x%n", ret1); // dfdd

final var ret2 = Character.codePointBefore(a, 3, 1);
System.out.printf("%c%n", ret2); // a

final var ret3 = Character.codePointBefore(a, 4, 1);
System.out.printf("%c%n", ret3); // b

static int codePointBefore (CharSequence seq, int index)

返回 CharSequence 的给定索引之前的代码点。 (机器翻译)

final var seq = "abc";
System.out.println(seq); // abc

final var ret1 = Character.codePointBefore(seq, 1);
System.out.printf("%c%n", ret1); // a

final var ret2 = Character.codePointBefore(seq, 2);
System.out.printf("%c%n", ret2); // b

final var ret3 = Character.codePointBefore(seq, 3);
System.out.printf("%c%n", ret3); // c

try {
    Character.codePointBefore(seq, 0);
} catch (IndexOutOfBoundsException e) {
    System.out.println(e);
}

// Result
// ↓
//java.lang.StringIndexOutOfBoundsException: Index -1 out of bounds for length 3
final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.println(Character.toString(codePoint)); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

final var seq = Character.toString(codePoint) + "ab";
System.out.println(seq); // 𝟝ab

final var ret1 = Character.codePointBefore(seq, 1);
System.out.printf("%c%n", ret1); // ?
System.out.printf("%x%n", ret1); // d835

final var ret2 = Character.codePointBefore(seq, 2);
System.out.printf("%c%n", ret2); // 𝟝

final var ret3 = Character.codePointBefore(seq, 3);
System.out.printf("%c%n", ret3); // a

final var ret4 = Character.codePointBefore(seq, 4);
System.out.printf("%c%n", ret4); // b

static int codePointCount (char[] a, int offset, int count)

返回字符数组参数的子数组中的 Unicode 代码点的数量。 (机器翻译)

final char[] a = "abc".toCharArray();
System.out.println(Arrays.toString(a)); // [a, b, c]

System.out.println(Character.codePointCount(a, 0, 0)); // 0
System.out.println(Character.codePointCount(a, 0, 1)); // 1
System.out.println(Character.codePointCount(a, 0, 2)); // 2
System.out.println(Character.codePointCount(a, 0, 3)); // 3
//Character.codePointCount(a, 0, 4); // IndexOutOfBoundsException

System.out.println(Character.codePointCount(a, 0, 3)); // 3
System.out.println(Character.codePointCount(a, 1, 2)); // 2
System.out.println(Character.codePointCount(a, 2, 1)); // 1
System.out.println(Character.codePointCount(a, 3, 0)); // 0
final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.println(Character.toString(codePoint)); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

final var seq = Character.toString(codePoint) + "ab";
System.out.println(seq); // 𝟝ab

final char[] a = seq.toCharArray();
System.out.println(Arrays.toString(a)); // [?, ?, a, b]

System.out.println(Character.codePointCount(a, 0, 0)); // 0
System.out.println(Character.codePointCount(a, 0, 1)); // 1
System.out.println(Character.codePointCount(a, 0, 2)); // 1
System.out.println(Character.codePointCount(a, 0, 3)); // 2
System.out.println(Character.codePointCount(a, 0, 4)); // 3

static int codePointCount (CharSequence seq, int beginIndex, int endIndex)

返回指定字符序列的文本范围内的 Unicode 代码点数。 (机器翻译)

final var seq = "abc";
System.out.println(seq); // [a, b, c]

System.out.println(Character.codePointCount(seq, 0, 0)); // 0
System.out.println(Character.codePointCount(seq, 0, 1)); // 1
System.out.println(Character.codePointCount(seq, 0, 2)); // 2
System.out.println(Character.codePointCount(seq, 0, 3)); // 3
//Character.codePointCount(seq, 0, 4); // IndexOutOfBoundsException

System.out.println(Character.codePointCount(seq, 0, 3)); // 3
System.out.println(Character.codePointCount(seq, 1, 3)); // 2
System.out.println(Character.codePointCount(seq, 2, 3)); // 1
System.out.println(Character.codePointCount(seq, 3, 3)); // 0
final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.println(Character.toString(codePoint)); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

final var seq = Character.toString(codePoint) + "ab";
System.out.println(seq); // 𝟝ab

System.out.println(Character.codePointCount(seq, 0, 0)); // 0
System.out.println(Character.codePointCount(seq, 0, 1)); // 1
System.out.println(Character.codePointCount(seq, 0, 2)); // 1
System.out.println(Character.codePointCount(seq, 0, 3)); // 2
System.out.println(Character.codePointCount(seq, 0, 4)); // 3

static int codePointOf (String name)

返回给定字符名称指定的 Unicode 字符的代码点值。 (机器翻译)

final var ret1 = Character.codePointOf("LATIN SMALL LETTER A");
System.out.printf("%c%n", ret1); // a

final var ret2 = Character.codePointOf("LATIN SMALL LETTER B");
System.out.printf("%c%n", ret2); // b

final var ret3 = Character.codePointOf("WHITE UP-POINTING TRIANGLE");
System.out.printf("%c%n", ret3); // △

final var ret4 = Character.codePointOf("MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE");
System.out.printf("%c%n", ret4); // 𝟝

static int compare (char x, char y)

从数字上比较两个字符值。 (机器翻译)

System.out.println(Character.compare('a', 'a')); // 0
System.out.println(Character.compare('a', 'b')); // -1
System.out.println(Character.compare('9', '0')); // 9
System.out.println(Character.compare('Z', 'Y')); // 1
System.out.println(Character.compare('□', '△')); // -18
System.out.println(Character.compare('a', 'A')); // 32

int compareTo (Character anotherCharacter)

从数字上比较两个 Character 对象。 (机器翻译)

final var value1 = Character.valueOf('a');
final var value2 = Character.valueOf('a');

System.out.println(value1.compareTo(value2)); // 0
final var value1 = Character.valueOf('a');
final var value2 = Character.valueOf('b');

System.out.println(value1.compareTo(value2)); // -1
final var value1 = Character.valueOf('9');
final var value2 = Character.valueOf('0');

System.out.println(value1.compareTo(value2)); // 9
final var value1 = Character.valueOf('Z');
final var value2 = Character.valueOf('Y');

System.out.println(value1.compareTo(value2)); // 1
final var value1 = Character.valueOf('□');
final var value2 = Character.valueOf('△');

System.out.println(value1.compareTo(value2)); // -18
final var value1 = Character.valueOf('a');
final var value2 = Character.valueOf('A');

System.out.println(value1.compareTo(value2)); // 32

Optional<DynamicConstantDesc<Character>> describeConstable ()

返回一个包含此实例的名义描述符的可选对象。 (机器翻译)

final var ret = Character.valueOf('a').describeConstable();

// Optional[DynamicConstantDesc[ConstantBootstraps::explicitCast(97)char]]
System.out.println(ret);

static int digit (char ch, int radix)

返回字符 ch 按指定基数表示的数值。 (机器翻译)

System.out.println(Character.digit('0', 10)); // 0
System.out.println(Character.digit('1', 10)); // 1
System.out.println(Character.digit('2', 10)); // 2
System.out.println(Character.digit('3', 10)); // 3
System.out.println(Character.digit('4', 10)); // 4
System.out.println(Character.digit('5', 10)); // 5
System.out.println(Character.digit('6', 10)); // 6
System.out.println(Character.digit('7', 10)); // 7
System.out.println(Character.digit('8', 10)); // 8
System.out.println(Character.digit('9', 10)); // 9
System.out.println(Character.digit('a', 10)); // -1
final var a = "0123456789abcdefABCDEF".toCharArray();

for (char ch : a) {
    System.out.printf("ch = %c : %d%n", ch, Character.digit(ch, 16));
}

// Result
// ↓
//ch = 0 : 0
//ch = 1 : 1
//ch = 2 : 2
//ch = 3 : 3
//ch = 4 : 4
//ch = 5 : 5
//ch = 6 : 6
//ch = 7 : 7
//ch = 8 : 8
//ch = 9 : 9
//ch = a : 10
//ch = b : 11
//ch = c : 12
//ch = d : 13
//ch = e : 14
//ch = f : 15
//ch = A : 10
//ch = B : 11
//ch = C : 12
//ch = D : 13
//ch = E : 14
//ch = F : 15

static int digit (int codePoint, int radix)

返回指定基数中指定字符(Unicode 代码点)的数值。 (机器翻译)

Please see also : digit(char ch, int radix)

final var codePoint = Character.toCodePoint('\uD835', '\uDFD8');

// MATHEMATICAL DOUBLE-STRUCK DIGIT ZERO
System.out.println(Character.getName(codePoint));

System.out.printf("%c%n", codePoint); // 𝟘
System.out.println(Character.digit(codePoint, 10)); // 0
final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

System.out.printf("%c%n", codePoint); // 𝟝
System.out.println(Character.digit(codePoint, 10)); // 5

boolean equals (Object obj)

将此对象与指定对象进行比较。 (机器翻译)

final var value1 = Character.valueOf('a');
final var value2 = Character.valueOf('a');

System.out.println(value1.equals(value2)); // true
final var value1 = Character.valueOf('a');
final var value2 = Character.valueOf('b');

System.out.println(value1.equals(value2)); // false
final var value1 = Character.valueOf('9');
final var value2 = Character.valueOf('0');

System.out.println(value1.equals(value2)); // false
final var value1 = Character.valueOf('Z');
final var value2 = Character.valueOf('Y');

System.out.println(value1.equals(value2)); // false
final var value1 = Character.valueOf('□');
final var value2 = Character.valueOf('△');

System.out.println(value1.equals(value2)); // false
final var value1 = Character.valueOf('a');
final var value2 = Character.valueOf('A');

System.out.println(value1.equals(value2)); // false

static char forDigit (int digit, int radix)

确定指定基数中特定数字的字符表示形式。 (机器翻译)

System.out.printf("%c%n", Character.forDigit(0, 10)); // 0
System.out.printf("%c%n", Character.forDigit(1, 10)); // 1
System.out.printf("%c%n", Character.forDigit(2, 10)); // 2
System.out.printf("%c%n", Character.forDigit(3, 10)); // 3
System.out.printf("%c%n", Character.forDigit(4, 10)); // 4
System.out.printf("%c%n", Character.forDigit(5, 10)); // 5
System.out.printf("%c%n", Character.forDigit(6, 10)); // 6
System.out.printf("%c%n", Character.forDigit(7, 10)); // 7
System.out.printf("%c%n", Character.forDigit(8, 10)); // 8
System.out.printf("%c%n", Character.forDigit(9, 10)); // 9

System.out.println(Character.forDigit(10, 10) == '\0'); // true
for (int i = 0; i < 16; i++) {
    System.out.printf("digit = %d : %c%n", i, Character.forDigit(i, 16));
}

// Result
// ↓
//digit = 0 : 0
//digit = 1 : 1
//digit = 2 : 2
//digit = 3 : 3
//digit = 4 : 4
//digit = 5 : 5
//digit = 6 : 6
//digit = 7 : 7
//digit = 8 : 8
//digit = 9 : 9
//digit = 10 : a
//digit = 11 : b
//digit = 12 : c
//digit = 13 : d
//digit = 14 : e
//digit = 15 : f

static byte getDirectionality (char ch)

返回给定字符的 Unicode 方向性属性。 (机器翻译)

System.out.println(Character.DIRECTIONALITY_EUROPEAN_NUMBER); // 3

System.out.println(Character.getDirectionality('1')); // 3
System.out.println(Character.getDirectionality('2')); // 3
System.out.println(Character.DIRECTIONALITY_PARAGRAPH_SEPARATOR); // 10

System.out.println(Character.getDirectionality('\n')); // 10
System.out.println(Character.getDirectionality('\r')); // 10

static byte getDirectionality (int codePoint)

返回给定字符(Unicode 代码点)的 Unicode 方向性属性。 (机器翻译)

Please see also : getDirectionality(char ch)

System.out.println(Character.DIRECTIONALITY_EUROPEAN_NUMBER); // 3

final var codePoint1 = Character.toCodePoint('\uD835', '\uDFD8');
System.out.printf("%c%n", codePoint1); // 𝟘
System.out.println(Character.getDirectionality(codePoint1)); // 3

final var codePoint2 = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint2); // 𝟝
System.out.println(Character.getDirectionality(codePoint2)); // 3

static String getName (int codePoint)

返回指定字符 codePoint 的名称,如果代码点未分配,则返回 null。 (机器翻译)

final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));
"abc".codePoints().forEach(codePoint -> {
    System.out.printf("%c : %s%n", codePoint, Character.getName(codePoint));
});

// Result
// ↓
//a : LATIN SMALL LETTER A
//b : LATIN SMALL LETTER B
//c : LATIN SMALL LETTER C

static int getNumericValue (char ch)

返回指定 Unicode 字符所代表的 int 值。 (机器翻译)

System.out.println(Character.getNumericValue('0')); // 0
System.out.println(Character.getNumericValue('1')); // 1
System.out.println(Character.getNumericValue('2')); // 2
System.out.println(Character.getNumericValue('3')); // 3
System.out.println(Character.getNumericValue('⑩')); // 10
System.out.println(Character.getNumericValue('Ⅺ')); // 11
System.out.println(Character.getNumericValue('⒓')); // 12
final var ch = '\u216C';
System.out.printf("%c%n", ch); // Ⅼ
System.out.println(Character.getNumericValue(ch)); // 50

static int getNumericValue (int codePoint)

返回指定字符(Unicode 代码点)所代表的 int 值。 (机器翻译)

Please see also : getNumericValue(char ch)

final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

System.out.println(Character.getNumericValue(codePoint)); // 5
"ⅩⅪⅫ".codePoints().forEach(codePoint -> {
    System.out.printf("%c : %d%n", codePoint, Character.getNumericValue(codePoint));
});

// Result
// ↓
//Ⅹ : 10
//Ⅺ : 11
//Ⅻ : 12

static int getType (char ch)

返回一个值,表示角色的一般类别。 (机器翻译)

System.out.println(Character.DECIMAL_DIGIT_NUMBER); // 9

System.out.println(Character.getType('1')); // 9
System.out.println(Character.getType('2')); // 9
System.out.println(Character.DASH_PUNCTUATION); // 20

System.out.println(Character.getType('-')); // 20
System.out.println(Character.getType('〜')); // 20

static int getType (int codePoint)

返回一个值,表示角色的一般类别。 (机器翻译)

Please see also : getType(char ch)

System.out.println(Character.DECIMAL_DIGIT_NUMBER); // 9

final var codePoint1 = Character.toCodePoint('\uD835', '\uDFD8');
System.out.printf("%c%n", codePoint1); // 𝟘
System.out.println(Character.getType(codePoint1)); // 9

final var codePoint2 = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint2); // 𝟝
System.out.println(Character.getType(codePoint2)); // 9

int hashCode ()

返回此字符的哈希码;等于调用 charValue() 的结果。 (机器翻译)

System.out.println(Character.valueOf('a').hashCode()); // 97
System.out.println(Character.valueOf('b').hashCode()); // 98
System.out.println(Character.valueOf('c').hashCode()); // 99
System.out.println(Character.valueOf('□').hashCode()); // 9633
System.out.println(Character.valueOf('△').hashCode()); // 9651

static int hashCode (char value)

返回 char 值的哈希码;与 Character.hashCode() 兼容。 (机器翻译)

System.out.println(Character.hashCode('a')); // 97
System.out.println(Character.hashCode('b')); // 98
System.out.println(Character.hashCode('c')); // 99
System.out.println(Character.hashCode('□')); // 9633
System.out.println(Character.hashCode('△')); // 9651

static char highSurrogate (int codePoint)

返回表示 UTF-16 编码中指定补充字符(Unicode 代码点)的代理对的前导代理(高代理代码单元)。 (机器翻译)

final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

final var high = Character.highSurrogate(codePoint);
System.out.println(Integer.toHexString(high)); // d835

final var low = Character.lowSurrogate(codePoint);
System.out.println(Integer.toHexString(low)); // dfdd

static boolean isAlphabetic (int codePoint)

确定指定字符(Unicode 代码点)是否是字母。 (机器翻译)

System.out.println(Character.isAlphabetic('a')); // true
System.out.println(Character.isAlphabetic('b')); // true
System.out.println(Character.isAlphabetic('X')); // true
System.out.println(Character.isAlphabetic('Y')); // true

System.out.println(Character.isAlphabetic('0')); // false
System.out.println(Character.isAlphabetic('1')); // false
System.out.println(Character.isAlphabetic('2')); // false

System.out.println(Character.isAlphabetic('□')); // false
System.out.println(Character.isAlphabetic('△')); // false

System.out.println(Character.isAlphabetic('Dž')); // true
System.out.println(Character.isAlphabetic('Lj')); // true

static boolean isBmpCodePoint (int codePoint)

确定指定字符(Unicode 代码点)是否位于基本多语言平面 (BMP) 中。 (机器翻译)

System.out.println(Character.isBmpCodePoint('a')); // true
System.out.println(Character.isBmpCodePoint('5')); // true
System.out.println(Character.isBmpCodePoint('△')); // true
final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

System.out.println(Character.isBmpCodePoint(codePoint)); // false

static boolean isDefined (char ch)

确定字符是否在 Unicode 中定义。 (机器翻译)

System.out.println(Character.isDefined('a')); // true
System.out.println(Character.isDefined('5')); // true
System.out.println(Character.isDefined('△')); // true

System.out.println(Character.isDefined('\uFFFF')); // false

static boolean isDefined (int codePoint)

确定字符(Unicode 代码点)是否在 Unicode 中定义。 (机器翻译)

Please see also : isDefined(char ch)

final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

System.out.println(Character.isDefined(codePoint)); // true
final var codePoint = Character.toCodePoint('\uFFFF', '\uFFFF');
System.out.println(Character.isDefined(codePoint)); // false

static boolean isDigit (char ch)

确定指定字符是否是数字。 (机器翻译)

System.out.println(Character.isDigit('0')); // true
System.out.println(Character.isDigit('1')); // true
System.out.println(Character.isDigit('2')); // true

System.out.println(Character.isDigit('a')); // false
System.out.println(Character.isDigit('b')); // false
System.out.println(Character.isDigit('c')); // false

System.out.println(Character.isDigit('٢')); // true
System.out.println(Character.isDigit('٣')); // true

System.out.println(Character.isDigit('Ⅲ')); // false
System.out.println(Character.isDigit('⑫')); // false

static boolean isDigit (int codePoint)

确定指定字符(Unicode 代码点)是否是数字。 (机器翻译)

Please see also : isDigit(char ch)

final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

System.out.println(Character.isDigit(codePoint)); // true

static boolean isEmoji (int codePoint)

确定指定字符(Unicode 代码点)是否是表情符号。 (机器翻译)

final var str = "\u0041\u2605\uD83D\uDE0A\u2139";
System.out.println(str); // A★😊ℹ

str.codePoints().forEach(codePoint -> {
    System.out.printf("%c (%#x)%n", codePoint, codePoint);
    System.out.println("  isEmoji = " + Character.isEmoji(codePoint));
    System.out.println("  isEmojiPresentation = "
            + Character.isEmojiPresentation(codePoint));
    System.out.println("  isExtendedPictographic = "
            + Character.isExtendedPictographic(codePoint));
});

// Result
// ↓
//A (0x41)
//  isEmoji = false
//  isEmojiPresentation = false
//  isExtendedPictographic = false
//★ (0x2605)
//  isEmoji = false
//  isEmojiPresentation = false
//  isExtendedPictographic = true
//😊 (0x1f60a)
//  isEmoji = true
//  isEmojiPresentation = true
//  isExtendedPictographic = true
//ℹ (0x2139)
//  isEmoji = true
//  isEmojiPresentation = false
//  isExtendedPictographic = true

static boolean isEmojiComponent (int codePoint)

确定指定字符(Unicode 代码点)是否是表情符号组件。 (机器翻译)

final var str = "\uD83D\uDC4F\uD83C\uDFFB";
System.out.println(str); // 👏🏻

str.codePoints().forEach(codePoint -> {
    System.out.printf("%c (%#x)%n", codePoint, codePoint);
    System.out.println("  isEmojiComponent = "
            + Character.isEmojiComponent(codePoint));
    System.out.println("  isEmojiModifier = "
            + Character.isEmojiModifier(codePoint));
    System.out.println("  isEmojiModifierBase = "
            + Character.isEmojiModifierBase(codePoint));
});

// Result
// ↓
//👏 (0x1f44f)
//  isEmojiComponent = false
//  isEmojiModifier = false
//  isEmojiModifierBase = true
//🏻 (0x1f3fb)
//  isEmojiComponent = true
//  isEmojiModifier = true
//  isEmojiModifierBase = false

static boolean isEmojiModifier (int codePoint)

确定指定字符(Unicode 代码点)是否是表情符号修饰符。 (机器翻译)

final var str = "\uD83D\uDC4F\uD83C\uDFFB";
System.out.println(str); // 👏🏻

str.codePoints().forEach(codePoint -> {
    System.out.printf("%c (%#x)%n", codePoint, codePoint);
    System.out.println("  isEmojiComponent = "
            + Character.isEmojiComponent(codePoint));
    System.out.println("  isEmojiModifier = "
            + Character.isEmojiModifier(codePoint));
    System.out.println("  isEmojiModifierBase = "
            + Character.isEmojiModifierBase(codePoint));
});

// Result
// ↓
//👏 (0x1f44f)
//  isEmojiComponent = false
//  isEmojiModifier = false
//  isEmojiModifierBase = true
//🏻 (0x1f3fb)
//  isEmojiComponent = true
//  isEmojiModifier = true
//  isEmojiModifierBase = false

static boolean isEmojiModifierBase (int codePoint)

确定指定字符(Unicode 代码点)是否是表情符号修饰符基础。 (机器翻译)

final var str = "\uD83D\uDC4F\uD83C\uDFFB";
System.out.println(str); // 👏🏻

str.codePoints().forEach(codePoint -> {
    System.out.printf("%c (%#x)%n", codePoint, codePoint);
    System.out.println("  isEmojiComponent = "
            + Character.isEmojiComponent(codePoint));
    System.out.println("  isEmojiModifier = "
            + Character.isEmojiModifier(codePoint));
    System.out.println("  isEmojiModifierBase = "
            + Character.isEmojiModifierBase(codePoint));
});

// Result
// ↓
//👏 (0x1f44f)
//  isEmojiComponent = false
//  isEmojiModifier = false
//  isEmojiModifierBase = true
//🏻 (0x1f3fb)
//  isEmojiComponent = true
//  isEmojiModifier = true
//  isEmojiModifierBase = false

static boolean isEmojiPresentation (int codePoint)

确定指定字符(Unicode 代码点)是否默认具有表情符号表示属性。 (机器翻译)

final var str = "\u0041\u2605\uD83D\uDE0A\u2139";
System.out.println(str); // A★😊ℹ

str.codePoints().forEach(codePoint -> {
    System.out.printf("%c (%#x)%n", codePoint, codePoint);
    System.out.println("  isEmoji = " + Character.isEmoji(codePoint));
    System.out.println("  isEmojiPresentation = "
            + Character.isEmojiPresentation(codePoint));
    System.out.println("  isExtendedPictographic = "
            + Character.isExtendedPictographic(codePoint));
});

// Result
// ↓
//A (0x41)
//  isEmoji = false
//  isEmojiPresentation = false
//  isExtendedPictographic = false
//★ (0x2605)
//  isEmoji = false
//  isEmojiPresentation = false
//  isExtendedPictographic = true
//😊 (0x1f60a)
//  isEmoji = true
//  isEmojiPresentation = true
//  isExtendedPictographic = true
//ℹ (0x2139)
//  isEmoji = true
//  isEmojiPresentation = false
//  isExtendedPictographic = true

static boolean isExtendedPictographic (int codePoint)

确定指定字符(Unicode 代码点)是否是扩展象形文字。 (机器翻译)

final var str = "\u0041\u2605\uD83D\uDE0A\u2139";
System.out.println(str); // A★😊ℹ

str.codePoints().forEach(codePoint -> {
    System.out.printf("%c (%#x)%n", codePoint, codePoint);
    System.out.println("  isEmoji = " + Character.isEmoji(codePoint));
    System.out.println("  isEmojiPresentation = "
            + Character.isEmojiPresentation(codePoint));
    System.out.println("  isExtendedPictographic = "
            + Character.isExtendedPictographic(codePoint));
});

// Result
// ↓
//A (0x41)
//  isEmoji = false
//  isEmojiPresentation = false
//  isExtendedPictographic = false
//★ (0x2605)
//  isEmoji = false
//  isEmojiPresentation = false
//  isExtendedPictographic = true
//😊 (0x1f60a)
//  isEmoji = true
//  isEmojiPresentation = true
//  isExtendedPictographic = true
//ℹ (0x2139)
//  isEmoji = true
//  isEmojiPresentation = false
//  isExtendedPictographic = true

static boolean isHighSurrogate (char ch)

确定给定的 char 值是否是 Unicode 高代理代码单元(也称为前导代理代码单元)。 (机器翻译)

final var high = '\uD835';
final var low = '\uDFDD';

System.out.println(Character.isSurrogate(high)); // true
System.out.println(Character.isHighSurrogate(high)); // true
System.out.println(Character.isLowSurrogate(high)); // false

System.out.println(Character.isSurrogate(low)); // true
System.out.println(Character.isHighSurrogate(low)); // false
System.out.println(Character.isLowSurrogate(low)); // true

System.out.println(Character.isSurrogatePair(high, low)); // true
System.out.println(Character.isSurrogatePair(low, high)); // false

final var codePoint = Character.toCodePoint(high, low);
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));
System.out.println(Character.isSurrogate('a')); // false
System.out.println(Character.isHighSurrogate('5')); // false
System.out.println(Character.isLowSurrogate('△')); // false

System.out.println(Character.isSurrogatePair('a', 'b')); // false

static boolean isIdentifierIgnorable (char ch)

确定指定的字符是否应被视为 Java 标识符或 Unicode 标识符中的可忽略字符。 (机器翻译)

System.out.println(Character.isIdentifierIgnorable('\u0000')); // true
System.out.println(Character.isIdentifierIgnorable('\u000E')); // true

System.out.println(Character.isIdentifierIgnorable('a')); // false
System.out.println(Character.isIdentifierIgnorable('5')); // false
System.out.println(Character.isIdentifierIgnorable('△')); // false

static boolean isIdentifierIgnorable (int codePoint)

确定指定字符(Unicode 代码点)是否应被视为 Java 标识符或 Unicode 标识符中的可忽略字符。 (机器翻译)

Please see also : isIdentifierIgnorable(char ch)

final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

System.out.println(Character.isIdentifierIgnorable(codePoint)); // false

static boolean isIdeographic (int codePoint)

确定指定字符(Unicode 代码点)是否为 Unicode 标准定义的 CJKV(中文、日文、韩文和越南文)表意文字。 (机器翻译)

System.out.println(Character.isIdeographic('一')); // true
System.out.println(Character.isIdeographic('空')); // true

System.out.println(Character.isIdeographic('a')); // false
System.out.println(Character.isIdeographic('5')); // false
System.out.println(Character.isIdeographic('△')); // false

static boolean isISOControl (char ch)

确定指定字符是否是 ISO 控制字符。 (机器翻译)

System.out.println(Character.isISOControl('\u0000')); // true
System.out.println(Character.isISOControl('\u007F')); // true

System.out.println(Character.isISOControl('a')); // false
System.out.println(Character.isISOControl('5')); // false
System.out.println(Character.isISOControl('△')); // false

static boolean isISOControl (int codePoint)

确定引用的字符(Unicode 代码点)是否是 ISO 控制字符。 (机器翻译)

Please see also : isISOControl(char ch)

final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

System.out.println(Character.isISOControl(codePoint)); // false

static boolean isJavaIdentifierPart (char ch)

确定指定字符是否可以作为 Java 标识符的一部分(而不是第一个字符)。 (机器翻译)

System.out.println(Character.isJavaIdentifierPart('a')); // true
System.out.println(Character.isJavaIdentifierPart('5')); // true
System.out.println(Character.isJavaIdentifierPart('$')); // true
System.out.println(Character.isJavaIdentifierPart('_')); // true

System.out.println(Character.isJavaIdentifierPart('+')); // false
System.out.println(Character.isJavaIdentifierPart('-')); // false
System.out.println(Character.isJavaIdentifierPart('△')); // false

static boolean isJavaIdentifierPart (int codePoint)

确定字符(Unicode 代码点)是否可以作为第一个字符以外的 Java 标识符的一部分。 (机器翻译)

Please see also : isJavaIdentifierPart(char ch)

final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

System.out.println(Character.isJavaIdentifierPart(codePoint)); // true

static boolean isJavaIdentifierStart (char ch)

确定指定字符是否可以作为 Java 标识符中的第一个字符。 (机器翻译)

System.out.println(Character.isJavaIdentifierStart('a')); // true
System.out.println(Character.isJavaIdentifierStart('$')); // true
System.out.println(Character.isJavaIdentifierStart('_')); // true

System.out.println(Character.isJavaIdentifierStart('5')); // false
System.out.println(Character.isJavaIdentifierStart('+')); // false
System.out.println(Character.isJavaIdentifierStart('-')); // false
System.out.println(Character.isJavaIdentifierStart('△')); // false

static boolean isJavaIdentifierStart (int codePoint)

确定该字符(Unicode 代码点)是否可以作为 Java 标识符中的第一个字符。 (机器翻译)

Please see also : isJavaIdentifierStart(char ch)

final var codePoint = Character.toCodePoint('\uD835', '\uDCBD');
System.out.printf("%c%n", codePoint); // 𝒽

// MATHEMATICAL SCRIPT SMALL H
System.out.println(Character.getName(codePoint));

System.out.println(Character.isJavaIdentifierStart(codePoint)); // true

static boolean isJavaLetter (char ch)

已弃用。由 isJavaIdentifierStart(char) 替代。 (机器翻译)

Deprecated.

static boolean isJavaLetterOrDigit (char ch)

已弃用。由 isJavaIdentifierPart(char) 替代。 (机器翻译)

Deprecated.

static boolean isLetter (char ch)

确定指定字符是否是字母。 (机器翻译)

System.out.println(Character.isLetter('a')); // true
System.out.println(Character.isLetter('b')); // true
System.out.println(Character.isLetter('X')); // true
System.out.println(Character.isLetter('Y')); // true

System.out.println(Character.isLetter('0')); // false
System.out.println(Character.isLetter('1')); // false
System.out.println(Character.isLetter('2')); // false

System.out.println(Character.isLetter('□')); // false
System.out.println(Character.isLetter('△')); // false

System.out.println(Character.isLetter('Dž')); // true
System.out.println(Character.isLetter('Lj')); // true

static boolean isLetter (int codePoint)

确定指定字符(Unicode 代码点)是否是字母。 (机器翻译)

Please see also : isLetter(char ch)

final var codePoint = Character.toCodePoint('\uD835', '\uDCBD');
System.out.printf("%c%n", codePoint); // 𝒽

// MATHEMATICAL SCRIPT SMALL H
System.out.println(Character.getName(codePoint));

System.out.println(Character.isLetter(codePoint)); // true

static boolean isLetterOrDigit (char ch)

确定指定字符是字母还是数字。 (机器翻译)

System.out.println(Character.isLetterOrDigit('a')); // true
System.out.println(Character.isLetterOrDigit('b')); // true
System.out.println(Character.isLetterOrDigit('X')); // true
System.out.println(Character.isLetterOrDigit('Y')); // true

System.out.println(Character.isLetterOrDigit('0')); // true
System.out.println(Character.isLetterOrDigit('1')); // true
System.out.println(Character.isLetterOrDigit('2')); // true

System.out.println(Character.isLetterOrDigit('□')); // false
System.out.println(Character.isLetterOrDigit('△')); // false

System.out.println(Character.isLetterOrDigit('Dž')); // true
System.out.println(Character.isLetterOrDigit('Lj')); // true

static boolean isLetterOrDigit (int codePoint)

确定指定字符(Unicode 代码点)是字母还是数字。 (机器翻译)

Please see also : isLetterOrDigit(char ch)

final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

System.out.println(Character.isLetterOrDigit(codePoint)); // true

static boolean isLowerCase (char ch)

确定指定字符是否是小写字符。 (机器翻译)

System.out.println(Character.isLowerCase('a')); // true
System.out.println(Character.isLowerCase('b')); // true
System.out.println(Character.isLowerCase('X')); // false
System.out.println(Character.isLowerCase('Y')); // false

System.out.println(Character.isLowerCase('0')); // false
System.out.println(Character.isLowerCase('1')); // false
System.out.println(Character.isLowerCase('2')); // false

System.out.println(Character.isLowerCase('□')); // false
System.out.println(Character.isLowerCase('△')); // false

System.out.println(Character.isLowerCase('Dž')); // false
System.out.println(Character.isLowerCase('Lj')); // false

static boolean isLowerCase (int codePoint)

确定指定字符(Unicode 代码点)是否是小写字符。 (机器翻译)

Please see also : isLowerCase(char ch)

final var codePoint = Character.toCodePoint('\uD835', '\uDCBD');
System.out.printf("%c%n", codePoint); // 𝒽

// MATHEMATICAL SCRIPT SMALL H
System.out.println(Character.getName(codePoint));

System.out.println(Character.isLowerCase(codePoint)); // true

static boolean isLowSurrogate (char ch)

确定给定的 char 值是否是 Unicode 低代理代码单元(也称为尾随代理代码单元)。 (机器翻译)

final var high = '\uD835';
final var low = '\uDFDD';

System.out.println(Character.isSurrogate(high)); // true
System.out.println(Character.isHighSurrogate(high)); // true
System.out.println(Character.isLowSurrogate(high)); // false

System.out.println(Character.isSurrogate(low)); // true
System.out.println(Character.isHighSurrogate(low)); // false
System.out.println(Character.isLowSurrogate(low)); // true

System.out.println(Character.isSurrogatePair(high, low)); // true
System.out.println(Character.isSurrogatePair(low, high)); // false

final var codePoint = Character.toCodePoint(high, low);
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));
System.out.println(Character.isSurrogate('a')); // false
System.out.println(Character.isHighSurrogate('5')); // false
System.out.println(Character.isLowSurrogate('△')); // false

System.out.println(Character.isSurrogatePair('a', 'b')); // false

static boolean isMirrored (char ch)

确定字符是否根据 Unicode 规范进行镜像。 (机器翻译)

System.out.println(Character.isMirrored('(')); // true
System.out.println(Character.isMirrored(')')); // true
System.out.println(Character.isMirrored('[')); // true
System.out.println(Character.isMirrored(']')); // true

System.out.println(Character.isMirrored('a')); // false
System.out.println(Character.isMirrored('b')); // false
System.out.println(Character.isMirrored('c')); // false

static boolean isMirrored (int codePoint)

确定指定字符(Unicode 代码点)是否根据 Unicode 规范进行镜像。 (机器翻译)

Please see also : isMirrored(char ch)

final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

System.out.println(Character.isMirrored(codePoint)); // false

static boolean isSpace (char ch)

已弃用。由 isWhitespace(char) 替代。 (机器翻译)

Deprecated.

static boolean isSpaceChar (char ch)

确定指定字符是否是 Unicode 空格字符。 (机器翻译)

System.out.println(Character.isSpaceChar(' ')); // true
System.out.println(Character.isSpaceChar('\u2028')); // true
System.out.println(Character.isSpaceChar('\u2029')); // true

System.out.println(Character.isSpaceChar('a')); // false
System.out.println(Character.isSpaceChar('5')); // false
System.out.println(Character.isSpaceChar('△')); // false

static boolean isSpaceChar (int codePoint)

确定指定字符(Unicode 代码点)是否是 Unicode 空格字符。 (机器翻译)

Please see also : isSpaceChar(char ch)

final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

System.out.println(Character.isSpaceChar(codePoint)); // false

static boolean isSupplementaryCodePoint (int codePoint)

确定指定字符(Unicode 代码点)是否在补充字符范围内。 (机器翻译)

System.out.println(Character.isSupplementaryCodePoint('a')); // false
System.out.println(Character.isSupplementaryCodePoint('5')); // false
System.out.println(Character.isSupplementaryCodePoint('△')); // false
final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

System.out.println(Character.isSupplementaryCodePoint(codePoint)); // true

static boolean isSurrogate (char ch)

确定给定的 char 值是否是 Unicode 代理代码单元。 (机器翻译)

final var high = '\uD835';
final var low = '\uDFDD';

System.out.println(Character.isSurrogate(high)); // true
System.out.println(Character.isHighSurrogate(high)); // true
System.out.println(Character.isLowSurrogate(high)); // false

System.out.println(Character.isSurrogate(low)); // true
System.out.println(Character.isHighSurrogate(low)); // false
System.out.println(Character.isLowSurrogate(low)); // true

System.out.println(Character.isSurrogatePair(high, low)); // true
System.out.println(Character.isSurrogatePair(low, high)); // false

final var codePoint = Character.toCodePoint(high, low);
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));
System.out.println(Character.isSurrogate('a')); // false
System.out.println(Character.isHighSurrogate('5')); // false
System.out.println(Character.isLowSurrogate('△')); // false

System.out.println(Character.isSurrogatePair('a', 'b')); // false

static boolean isSurrogatePair (char high, char low)

确定指定的 char 值对是否是有效的 Unicode 代理对。 (机器翻译)

final var high = '\uD835';
final var low = '\uDFDD';

System.out.println(Character.isSurrogate(high)); // true
System.out.println(Character.isHighSurrogate(high)); // true
System.out.println(Character.isLowSurrogate(high)); // false

System.out.println(Character.isSurrogate(low)); // true
System.out.println(Character.isHighSurrogate(low)); // false
System.out.println(Character.isLowSurrogate(low)); // true

System.out.println(Character.isSurrogatePair(high, low)); // true
System.out.println(Character.isSurrogatePair(low, high)); // false

final var codePoint = Character.toCodePoint(high, low);
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));
System.out.println(Character.isSurrogate('a')); // false
System.out.println(Character.isHighSurrogate('5')); // false
System.out.println(Character.isLowSurrogate('△')); // false

System.out.println(Character.isSurrogatePair('a', 'b')); // false

static boolean isTitleCase (char ch)

确定指定字符是否是标题字符。 (机器翻译)

System.out.println(Character.isTitleCase('Lj')); // true
System.out.println(Character.isTitleCase('Dž')); // true

System.out.println(Character.isTitleCase('a')); // false
System.out.println(Character.isTitleCase('b')); // false
System.out.println(Character.isTitleCase('c')); // false

static boolean isTitleCase (int codePoint)

确定指定字符(Unicode 代码点)是否是标题字符。 (机器翻译)

Please see also : isTitleCase(char ch)

final var codePoint = Character.toCodePoint('\uD835', '\uDCBD');
System.out.printf("%c%n", codePoint); // 𝒽

// MATHEMATICAL SCRIPT SMALL H
System.out.println(Character.getName(codePoint));

System.out.println(Character.isTitleCase(codePoint)); // false

static boolean isUnicodeIdentifierPart (char ch)

确定指定字符是否可以作为第一个字符以外的 Unicode 标识符的一部分。 (机器翻译)

System.out.println(Character.isUnicodeIdentifierPart('a')); // true
System.out.println(Character.isUnicodeIdentifierPart('5')); // true
System.out.println(Character.isUnicodeIdentifierPart('_')); // true

System.out.println(Character.isUnicodeIdentifierPart('$')); // false
System.out.println(Character.isUnicodeIdentifierPart('+')); // false
System.out.println(Character.isUnicodeIdentifierPart('-')); // false
System.out.println(Character.isUnicodeIdentifierPart('△')); // false

static boolean isUnicodeIdentifierPart (int codePoint)

确定指定字符(Unicode 代码点)是否可以作为第一个字符以外的 Unicode 标识符的一部分。 (机器翻译)

Please see also : isUnicodeIdentifierPart(char ch)

final var codePoint = Character.toCodePoint('\uD835', '\uDCBD');
System.out.printf("%c%n", codePoint); // 𝒽

// MATHEMATICAL SCRIPT SMALL H
System.out.println(Character.getName(codePoint));

System.out.println(Character.isUnicodeIdentifierPart(codePoint)); // true

static boolean isUnicodeIdentifierStart (char ch)

确定指定字符是否可以作为 Unicode 标识符中的第一个字符。 (机器翻译)

System.out.println(Character.isUnicodeIdentifierStart('a')); // true
System.out.println(Character.isUnicodeIdentifierStart('Ⅱ')); // true

System.out.println(Character.isUnicodeIdentifierStart('5')); // false
System.out.println(Character.isUnicodeIdentifierStart('_')); // false
System.out.println(Character.isUnicodeIdentifierStart('$')); // false
System.out.println(Character.isUnicodeIdentifierStart('+')); // false
System.out.println(Character.isUnicodeIdentifierStart('-')); // false
System.out.println(Character.isUnicodeIdentifierStart('△')); // false

static boolean isUnicodeIdentifierStart (int codePoint)

确定指定字符(Unicode 代码点)是否可以作为 Unicode 标识符中的第一个字符。 (机器翻译)

Please see also : isUnicodeIdentifierStart(char ch)

final var codePoint = Character.toCodePoint('\uD835', '\uDCBD');
System.out.printf("%c%n", codePoint); // 𝒽

// MATHEMATICAL SCRIPT SMALL H
System.out.println(Character.getName(codePoint));

System.out.println(Character.isUnicodeIdentifierStart(codePoint)); // true

static boolean isUpperCase (char ch)

确定指定字符是否是大写字符。 (机器翻译)

System.out.println(Character.isUpperCase('A')); // true
System.out.println(Character.isUpperCase('B')); // true
System.out.println(Character.isUpperCase('x')); // false
System.out.println(Character.isUpperCase('y')); // false

System.out.println(Character.isUpperCase('0')); // false
System.out.println(Character.isUpperCase('1')); // false
System.out.println(Character.isUpperCase('2')); // false

System.out.println(Character.isUpperCase('□')); // false
System.out.println(Character.isUpperCase('△')); // false

System.out.println(Character.isUpperCase('Dž')); // false
System.out.println(Character.isUpperCase('Lj')); // false

static boolean isUpperCase (int codePoint)

确定指定字符(Unicode 代码点)是否是大写字符。 (机器翻译)

Please see also : isUpperCase(char ch)

final var codePoint = Character.toCodePoint('\uD801', '\uDCB2');
System.out.printf("%c%n", codePoint); // 𐒲

// OSAGE CAPITAL LETTER AIN
System.out.println(Character.getName(codePoint));

System.out.println(Character.isUpperCase(codePoint)); // true

static boolean isValidCodePoint (int codePoint)

确定指定的代码点是否是有效的 Unicode 代码点值。 (机器翻译)

System.out.println(Character.isValidCodePoint('a')); // true
System.out.println(Character.isValidCodePoint('5')); // true
System.out.println(Character.isValidCodePoint('△')); // true

System.out.println(Character.isValidCodePoint(Character.MIN_CODE_POINT)); // true
System.out.println(Character.isValidCodePoint(Character.MIN_CODE_POINT - 1)); // false

System.out.println(Character.isValidCodePoint(Character.MAX_CODE_POINT)); // true
System.out.println(Character.isValidCodePoint(Character.MAX_CODE_POINT + 1)); // false

static boolean isWhitespace (char ch)

根据 Java 确定指定字符是否为空格。 (机器翻译)

System.out.println(Character.isWhitespace(' ')); // true
System.out.println(Character.isWhitespace('\r')); // true
System.out.println(Character.isWhitespace('\n')); // true
System.out.println(Character.isWhitespace('\t')); // true

System.out.println(Character.isWhitespace('a')); // false
System.out.println(Character.isWhitespace('5')); // false
System.out.println(Character.isWhitespace('△')); // false

static boolean isWhitespace (int codePoint)

根据 Java 确定指定字符(Unicode 代码点)是否为空格。 (机器翻译)

Please see also : isWhitespace(char ch)

final var codePoint = Character.toCodePoint('\uD835', '\uDCBD');
System.out.printf("%c%n", codePoint); // 𝒽

// MATHEMATICAL SCRIPT SMALL H
System.out.println(Character.getName(codePoint));

System.out.println(Character.isWhitespace(codePoint)); // false

static char lowSurrogate (int codePoint)

返回表示 UTF-16 编码中指定补充字符(Unicode 代码点)的代理对的尾随代理(低代理代码单元)。 (机器翻译)

final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

final var high = Character.highSurrogate(codePoint);
System.out.println(Integer.toHexString(high)); // d835

final var low = Character.lowSurrogate(codePoint);
System.out.println(Integer.toHexString(low)); // dfdd

static int offsetByCodePoints (char[] a, int start, int count, int index, int codePointOffset)

返回给定 char 子数组中与给定索引偏移 codePointOffset 代码点的索引。 (机器翻译)

final var a = "abc".toCharArray();
System.out.println(Arrays.toString(a)); // [a, b, c]

System.out.println(Character.offsetByCodePoints(a, 0, 3, 0, 0)); // 0
System.out.println(Character.offsetByCodePoints(a, 0, 3, 1, 0)); // 1
System.out.println(Character.offsetByCodePoints(a, 0, 3, 2, 0)); // 2
System.out.println(Character.offsetByCodePoints(a, 0, 3, 3, 0)); // 3

System.out.println(Character.offsetByCodePoints(a, 0, 3, 0, 0)); // 0
System.out.println(Character.offsetByCodePoints(a, 0, 3, 0, 1)); // 1
System.out.println(Character.offsetByCodePoints(a, 0, 3, 0, 2)); // 2
System.out.println(Character.offsetByCodePoints(a, 0, 3, 0, 3)); // 3

System.out.println(Character.offsetByCodePoints(a, 0, 3, 0, 0)); // 0
System.out.println(Character.offsetByCodePoints(a, 1, 2, 1, 0)); // 1
System.out.println(Character.offsetByCodePoints(a, 2, 1, 2, 0)); // 2
System.out.println(Character.offsetByCodePoints(a, 3, 0, 3, 0)); // 3
final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

final var seq = Character.toString(codePoint) + "ab";
System.out.println(seq); // 𝟝ab

final char[] a = seq.toCharArray();
System.out.println(Arrays.toString(a)); // [?, ?, a, b]

System.out.println(Character.offsetByCodePoints(a, 0, 4, 0, 0)); // 0
System.out.println(Character.offsetByCodePoints(a, 0, 4, 1, 0)); // 1
System.out.println(Character.offsetByCodePoints(a, 0, 4, 2, 0)); // 2
System.out.println(Character.offsetByCodePoints(a, 0, 4, 3, 0)); // 3
System.out.println(Character.offsetByCodePoints(a, 0, 4, 4, 0)); // 4

System.out.println(Character.offsetByCodePoints(a, 0, 4, 0, 0)); // 0
System.out.println(Character.offsetByCodePoints(a, 0, 4, 0, 1)); // 2
System.out.println(Character.offsetByCodePoints(a, 0, 4, 0, 2)); // 3
System.out.println(Character.offsetByCodePoints(a, 0, 4, 0, 3)); // 4

System.out.println(Character.offsetByCodePoints(a, 1, 3, 1, 0)); // 1
System.out.println(Character.offsetByCodePoints(a, 1, 3, 2, 0)); // 2
System.out.println(Character.offsetByCodePoints(a, 1, 3, 3, 0)); // 3
System.out.println(Character.offsetByCodePoints(a, 1, 3, 4, 0)); // 4

static int offsetByCodePoints (CharSequence seq, int index, int codePointOffset)

返回给定字符序列中与给定索引偏移 codePointOffset 代码点的索引。 (机器翻译)

final var seq = "abc";
System.out.println(seq); // abc

System.out.println(Character.offsetByCodePoints(seq, 0, 0)); // 0
System.out.println(Character.offsetByCodePoints(seq, 1, 0)); // 1
System.out.println(Character.offsetByCodePoints(seq, 2, 0)); // 2
System.out.println(Character.offsetByCodePoints(seq, 3, 0)); // 3

System.out.println(Character.offsetByCodePoints(seq, 0, 0)); // 0
System.out.println(Character.offsetByCodePoints(seq, 0, 1)); // 1
System.out.println(Character.offsetByCodePoints(seq, 0, 2)); // 2
System.out.println(Character.offsetByCodePoints(seq, 0, 3)); // 3
final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

final var seq = Character.toString(codePoint) + "ab";
System.out.println(seq); // 𝟝ab

System.out.println(Character.offsetByCodePoints(seq, 0, 0)); // 0
System.out.println(Character.offsetByCodePoints(seq, 1, 0)); // 1
System.out.println(Character.offsetByCodePoints(seq, 2, 0)); // 2
System.out.println(Character.offsetByCodePoints(seq, 3, 0)); // 3
System.out.println(Character.offsetByCodePoints(seq, 4, 0)); // 4

System.out.println(Character.offsetByCodePoints(seq, 0, 0)); // 0
System.out.println(Character.offsetByCodePoints(seq, 0, 1)); // 2
System.out.println(Character.offsetByCodePoints(seq, 0, 2)); // 3
System.out.println(Character.offsetByCodePoints(seq, 0, 3)); // 4

static char reverseBytes (char ch)

返回通过反转指定 char 值中的字节顺序而获得的值。 (机器翻译)

final var value = 'a';
final var ret = Character.reverseBytes(value);

System.out.println("-- print --");
System.out.printf("%04x%n", (short) value);
System.out.printf("%04x%n", (short) ret);

// Result
// ↓
//-- print --
//0061
//6100
final var value = '△';
final var ret = Character.reverseBytes(value);

System.out.println("-- print --");
System.out.printf("%04x%n", (short) value);
System.out.printf("%04x%n", (short) ret);

// Result
// ↓
//-- print --
//25b3
//b325

static char[] toChars (int codePoint)

将指定的字符(Unicode 代码点)转换为存储在 char 数组中的 UTF-16 表示形式。 (机器翻译)

final var ret = Character.toChars('a');
System.out.println(ret.length); // 1
System.out.println(Integer.toHexString(ret[0])); // 61
final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

final var ret = Character.toChars(codePoint);
System.out.println(ret.length); // 2
System.out.println(Integer.toHexString(ret[0])); // d835
System.out.println(Integer.toHexString(ret[1])); // dfdd

static int toChars (int codePoint, char[] dst, int dstIndex)

将指定字符(Unicode 代码点)转换为其 UTF-16 表示形式。 (机器翻译)

final var dst = new char[3];
System.out.println(Arrays.toString(dst)); // [ ,  ,  ]

System.out.println(Character.toChars('a', dst, 0)); // 1
System.out.println(Arrays.toString(dst)); // [a,  ,  ]

System.out.println(Character.toChars('b', dst, 1)); // 1
System.out.println(Arrays.toString(dst)); // [a, b,  ]

System.out.println(Character.toChars('c', dst, 2)); // 1
System.out.println(Arrays.toString(dst)); // [a, b, c]
final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

final var dst = new char[2];
System.out.println(Arrays.toString(dst)); // [ ,  ]

final var ret = Character.toChars(codePoint, dst, 0);
System.out.println(ret); // 2
System.out.println(Integer.toHexString(dst[0])); // d835
System.out.println(Integer.toHexString(dst[1])); // dfdd

static int toCodePoint (char high, char low)

将指定的代理对转换为其补充代码点值。 (机器翻译)

final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');
System.out.printf("%c%n", codePoint); // 𝟝

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

static char toLowerCase (char ch)

使用来自 UnicodeData 文件中的大小写映射信息将字符参数转换为小写。 (机器翻译)

System.out.println(Character.toLowerCase('A')); // a
System.out.println(Character.toLowerCase('B')); // b
System.out.println(Character.toLowerCase('C')); // c

System.out.println(Character.toLowerCase('x')); // x
System.out.println(Character.toLowerCase('y')); // y

System.out.println(Character.toLowerCase('0')); // 0
System.out.println(Character.toLowerCase('1')); // 1

System.out.println(Character.toLowerCase('□')); // □
System.out.println(Character.toLowerCase('△')); // △

static int toLowerCase (int codePoint)

使用来自 UnicodeData 文件中的大小写映射信息将字符(Unicode 代码点)参数转换为小写。 (机器翻译)

Please see also : toLowerCase(char ch)

final var codePoint = Character.toCodePoint('\uD801', '\uDCB2');
System.out.printf("%c%n", codePoint); // 𐒲

// OSAGE CAPITAL LETTER AIN
System.out.println(Character.getName(codePoint));

final var ret = Character.toLowerCase(codePoint);
System.out.printf("%c%n", ret); // 𐓚

// OSAGE SMALL LETTER AIN
System.out.println(Character.getName(ret));

String toString ()

返回表示此字符值的字符串对象。 (机器翻译)

final var ret1 = Character.valueOf('a').toString();
System.out.println(ret1); // a

final var ret2 = Character.valueOf('5').toString();
System.out.println(ret2); // 5

final var ret3 = Character.valueOf('△').toString();
System.out.println(ret3); // △

static String toString (char c)

返回表示指定字符的字符串对象。 (机器翻译)

final var ret1 = Character.toString('a');
System.out.println(ret1); // a

final var ret2 = Character.toString('5');
System.out.println(ret2); // 5

final var ret3 = Character.toString('△');
System.out.println(ret3); // △

static String toString (int codePoint)

返回表示指定字符(Unicode 代码点)的字符串对象。 (机器翻译)

final var codePoint = Character.toCodePoint('\uD835', '\uDFDD');

// MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE
System.out.println(Character.getName(codePoint));

final var ret = Character.toString(codePoint);
System.out.println(ret); // 𝟝

static char toTitleCase (char ch)

使用来自 UnicodeData 文件中的大小写映射信息将字符参数转换为标题大小写。 (机器翻译)

System.out.println(Character.toTitleCase('a')); // A
System.out.println(Character.toTitleCase('b')); // B
System.out.println(Character.toTitleCase('c')); // C

System.out.println(Character.toTitleCase('0')); // 0
System.out.println(Character.toTitleCase('1')); // 1

System.out.println(Character.toTitleCase('□')); // □
System.out.println(Character.toTitleCase('△')); // △

static int toTitleCase (int codePoint)

使用来自 UnicodeData 文件中的大小写映射信息将字符(Unicode 代码点)参数转换为标题大小写。 (机器翻译)

Please see also : toTitleCase(char ch)

final var codePoint = Character.toCodePoint('\uD801', '\uDCDA');
System.out.println(Character.toString(codePoint)); // 𐓚

// OSAGE SMALL LETTER AIN
System.out.println(Character.getName(codePoint));

final var ret = Character.toTitleCase(codePoint);
System.out.println(Character.toString(ret)); // 𐒲

// OSAGE SMALL LETTER AIN
System.out.println(Character.getName(codePoint));

static char toUpperCase (char ch)

使用来自 UnicodeData 文件中的大小写映射信息将字符参数转换为大写。 (机器翻译)

System.out.println(Character.toUpperCase('a')); // A
System.out.println(Character.toUpperCase('b')); // B
System.out.println(Character.toUpperCase('c')); // C

System.out.println(Character.toUpperCase('X')); // X
System.out.println(Character.toUpperCase('Y')); // Y

System.out.println(Character.toUpperCase('0')); // 0
System.out.println(Character.toUpperCase('1')); // 1

System.out.println(Character.toUpperCase('□')); // □
System.out.println(Character.toUpperCase('△')); // △

static int toUpperCase (int codePoint)

使用来自 UnicodeData 文件中的大小写映射信息将字符(Unicode 代码点)参数转换为大写。 (机器翻译)

Please see also : toUpperCase(char ch)

final var codePoint = Character.toCodePoint('\uD801', '\uDCDA');
System.out.println(Character.toString(codePoint)); // 𐓚

// OSAGE SMALL LETTER AIN
System.out.println(Character.getName(codePoint));

final var ret = Character.toUpperCase(codePoint);
System.out.println(Character.toString(ret)); // 𐒲

// OSAGE SMALL LETTER AIN
System.out.println(Character.getName(codePoint));

static Character valueOf (char c)

返回表示指定字符值的字符实例。 (机器翻译)

final var ret1 = Character.valueOf('a');
System.out.println(ret1); // a

final var ret2 = Character.valueOf('5');
System.out.println(ret2); // 5

final var ret3 = Character.valueOf('△');
System.out.println(ret3); // △

相关文章

To top of page