Java Character isUnicodeIdentifierStart()方法
java.lang.Character.isUnicodeIdentifierStart(int codePoint) 确定指定字符(Unicode代码点)是允许作为Unicode标识符的第一个字符。
字符以一个Unicode标识符开始,当且仅当下面的一个条件为true:
isLetter(codePoint) 返回 true
getType(codePoint) 返回LETTER_NUMBER.
1 语法
public static boolean isUnicodeIdentifierStart(int codePoint)
2 参数
codePoint:进行测试的字符(Unicode代码点)
3 返回值
方法适用于字符以一个Unicode标识符开始则返回true,否则返回false。
4 示例
package com.yiidian;
/**
* 一点教程网: http://www.yiidian.com
*/
/**
* Java Character isUnicodeIdentifierStart()方法
*/
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 = 0x037e; // represents GREEK QUESTION MARK
cp2 = 0x05d1; // represents HEBREW LETTER BET
// create 2 boolean primitives b1, b2
boolean b1, b2;
/**
* check if cp1, cp2 may start a Unicode identifier
* and assign results to b1, b2
*/
b1 = Character.isUnicodeIdentifierStart(cp1);
b2 = Character.isUnicodeIdentifierStart(cp2);
String str1 = "cp1 may start a Unicode identifier is " + b1;
String str2 = "cp2 may start a Unicode identifier is " + b2;
// print b1, b2 values
System.out.println( str1 );
System.out.println( str2 );
}
}
输出结果为:
cp1 may start a Unicode identifier is false
cp2 may start a Unicode identifier is true