LAST UPDATED: NOVEMBER 24, 2020
Java Character isUnicodeIdentifierPart(char ch) Method
Java isUnicodeIdentifierPart(char ch)
is a part of Character
class. This method is used to check whether the specified character may be part of a Unicode identifier as other than the first character.
This method does not support supplementary characters. A character may be part of a Unicode identifier if and only if one of the following statements is true:
- it is a letter
- it is a connecting punctuation character (such as
'_'
)
- it is a digit
- it is a numeric letter (such as a Roman numeral character)
- it is a combining mark
- it is a non-spacing mark
Syntax:
public static boolean isUnicodeIdentifierPart(char ch)
Parameters:
The parameter passed is the character to be checked whether it is a part of the Unicode identifier as other than the first character.
Returns:
Returns the boolean value true
if the specified character is a part of Unicode identifier else return false
.
Example 1:
Here, the characters are checked whether they are part of Unicode identifiers or not.
public class StudyTonight
{
public static void main(String[] args)
{
char ch1 = '~';
char ch2 = 'd';
char ch3 = '\u01f2';
char ch4 = '0';
char ch5 = '7';
boolean b1 = Character.isUnicodeIdentifierPart(ch1);
boolean b2 = Character.isUnicodeIdentifierPart(ch2);
boolean b3 = Character.isUnicodeIdentifierPart(ch3);
boolean b4 = Character.isUnicodeIdentifierPart(ch4);
boolean b5 = Character.isUnicodeIdentifierPart(ch5);
System.out.println(ch1 +" is a part of Unicode identifier??: "+b1);
System.out.println(ch2 +" is a part of Unicode identifier??: "+b2);
System.out.println(ch3 +" is a part of Unicode identifier??: "+b3);
System.out.println(ch4 +" is a part of Unicode identifier?? : "+b4);
System.out.println(ch5 +" is a part of Unicode identifier??: "+b5);
}
}
~ is a part of Unicode identifier??: false
d is a part of Unicode identifier??: true
? is a part of Unicode identifier??: true
0 is a part of Unicode identifier?? : true
7 is a part of Unicode identifier??: true
Example 2:
Here is a user-defined example where anyone using this code can put a value of his choice and get the equivalent output.
import java.util.Scanner;
public class StudyTonight
{
public static void main(String[] args)
{
try
{
System.out.print("Enter the character: ");
Scanner sc = new Scanner(System.in);
char ch = sc.next().charAt(0);
boolean b = Character.isUnicodeIdentifierPart(ch);
System.out.println(ch + " is a part of Unicode identifier??: "+b);
}
catch(Exception e)
{
System.out.println("Invalid Input!!");
}
}
}
Enter the character: @
@ is a part of Unicode identifier??: false
***********************************************
Enter the character: e
e is a part of Unicode identifier??: true
Live Example:
Here, you can test the live code example. You can execute the example for different values, even can edit and write your examples to test the Java code.