java.lang.Character.isUnicodeIdentifierPart(int codePoint)方法實例
java.lang.Character.isUnicodeIdentifierPart(int codePoint) 確定指定字符(Unicode代碼點)可能是Unicode標識符中除首字符以外的部分。
字符可以是Unicode標識符的一部分,當且僅當下列一個語句是正確的:
它是一個字母
它是一個連接標點字符(如「_」)
它是一個數字
它是一個數字字母(如羅馬數字字符)
它是一個組合標誌
它是一個非空格標記
isIdentifierIgnorable此字符返回true。
聲明
以下是**java.lang.Character.isUnicodeIdentifierPart()**方法的聲明
public static boolean isUnicodeIdentifierPart(int codePoint)
參數
- codePoint - 進行測試的字符(Unicode代碼點)
返回值
如果字符可以是Unicode標識符的一部分此方法返回true,否則返回false。
異常
- NA
例子
下面的例子顯示lang.Character.isUnicodeIdentifierPart()方法的使用。
package com.yiibai; 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