Java Character isUnicodeIdentifierPart(int codePoint) Method

Java isUnicodeIdentifierPart(int codePoint) is a part of Character class. This method is used to check whether the specified Unicode codepoint character may be part of a Unicode identifier as other than the first character.

This method also supports 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(int codePoint)

Parameters:

The parameter passed is the Unicode codepoint 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 codepoint 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)
	{  
		int cp1 = 32;  
		int cp2 = 60;  
		int cp3 = 119;  
		int cp4 = 93;   
		int cp5 = 1232;  

		boolean b1 = Character.isUnicodeIdentifierPart(cp1);  
		boolean b2 = Character.isUnicodeIdentifierPart(cp2);  
		boolean b3 = Character.isUnicodeIdentifierPart(cp3);  
		boolean b4 = Character.isUnicodeIdentifierPart(cp4);  
		boolean b5 = Character.isUnicodeIdentifierPart(cp5);  

		System.out.println((char)cp1 +" is a part of Unicode identifier??:  "+b1);  
		System.out.println((char)cp2 +" is a part of Unicode identifier??:  "+b2);  
		System.out.println((char)cp3 +" is a part of Unicode identifier??:  "+b3);  
		System.out.println((char)cp4 +" is a part of Unicode identifier??:  "+b4);  
		System.out.println((char)cp5 +" is a part of Unicode identifier??:  "+b5);  
	}  
} 


is a part of Unicode identifier??: false
< is a part of Unicode identifier??: false
w is a part of Unicode identifier??: true
] is a part of Unicode identifier??: false
? 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 Unicode character: ");  
			Scanner sc = new Scanner(System.in);        
			int cp = sc.nextInt(); 
			boolean b = Character.isUnicodeIdentifierPart(cp);
			System.out.println((char)cp + " is a part of Unicode Identifier?: "+b);
		}
		catch(Exception e)
		{
			System.out.println("Invalid Input!!");
		}
	}
}


Enter the Unicode character: 78
N is a part of Unicode Identifier?: true
**********************************************
Enter the Unicode character: 44
, is a part of Unicode Identifier?: false

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.