Java.lang.Character.isUnicodeIdentifierPart() 方法
描述
java.lang.Character.isUnicodeIdentifierPart(int codePoint) 确定指定字符(Unicode 代码点)是否可能是 Unicode 标识符的一部分,而不是第一个字符。
当且仅当以下陈述之一为真时,字符才可能是 Unicode 标识符的一部分 −
它是个字母
它是一个连接标点符号(例如'_')
这是一个数字
它是一个数字字母(如罗马数字字符)
它是一个组合标记
它是一个非间距标记
is IdentifierIgnorable 为该字符返回 true。
声明
以下是 java.lang.Character.isUnicodeIdentifierPart() 方法的声明。
public static boolean isUnicodeIdentifierPart(int codePoint)
参数
codePoint − 要测试的字符(Unicode 代码点)
返回值
如果字符可能是 Unicode 标识符的一部分,则此方法返回 true,否则返回 false。
异常
NA
示例
下面的例子展示了 lang.Character.isUnicodeIdentifierPart() 方法的使用。
package com.tutorialspoint;
import java.lang.*;
public class CharacterDemo {
public static void main(String[] args) {
// create 2 int primitives cp1, cp2
int cp1, cp2;
// assign values to cp1, cp2
cp1 = 0x053e; // represents ARMENIAN CAPITAL LETTER CA
cp2 = 0x0040; // represents @
// create 2 boolean primitives b1, b2
boolean b1, b2;
/**
* check if cp1, cp2 may be part of a Unicode identifier
* and assign results to b1, b2.
*/
b1 = Character.isUnicodeIdentifierPart(cp1);
b2 = Character.isUnicodeIdentifierPart(cp2);
String str1 = "cp1 may be part of a Unicode identifier is " + b1;
String str2 = "cp2 may be part of a Unicode identifier is " + b2;
// print b1, b2 values
System.out.println( str1 );
System.out.println( str2 );
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
cp1 may be part of a Unicode identifier is true cp2 may be part of a Unicode identifier is false

