Java.lang.Character.isUnicodeIdentifierStart() Method
Description
The java.lang.Character.isUnicodeIdentifierStart(int codePoint) determines if the specified character (Unicode code point) is permissible as the first character in a Unicode identifier.
A character may start a Unicode identifier if and only if one of the following conditions is true −
- isLetter(codePoint) returns true
- getType(codePoint) returns LETTER_NUMBER.
Declaration
Following is the declaration for java.lang.Character.isUnicodeIdentifierStart() method
public static boolean isUnicodeIdentifierStart(int codePoint)
Parameters
codePoint − the character (Unicode code point) to be tested
Return Value
This method returns true if the character may start a Unicode identifier, false otherwise.
Exception
NA
Example
The following example shows the usage of lang.Character.isUnicodeIdentifierStart() method.
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 = 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 );
}
}
Let us compile and run the above program, this will produce the following result −
cp1 may start a Unicode identifier is false cp2 may start a Unicode identifier is true
java_lang_character.htm
Advertisements