New Tutorials:   NUMPY    TKINTER    KOTLIN    JAVASCRIPT    SASS/SCSS    PL/SQL    Matplotlib    C++ Programs

Java Character isUnicodeIdentifierStart(char ch) Method

Java isUnicodeIdentifierStart(char ch) is a part of Character class. This method is used to check whether the specified character is allowed as the first character in a Unicode identifier or not.

This method does not support supplementary characters. A character may start a Unicode identifier if and only if one of the following conditions is true:

  • isLetter(ch) returns true
  • getType(ch) returns LETTER_NUMBER.

Syntax:

public static boolean isUnicodeIdentifierStart(char ch)

Parameters:

The parameter passed is the character to be checked whether it is allowed as a start character in the Unicode identifier.

Returns:

Returns the boolean value true if the specified character is allowed as the first character of Unicode identifier else return false.

Example 1:

Here, the characters are checked whether they are allowed as start character of Unicode identifier or not.

public class StudyTonight
{  
	public static void main(String[] args)
	{  
		char ch1 = '0';  
		char ch2 = 'd';  
		char ch3 = 'D';  
		char ch4 = '$';   
		char ch5 = '_';  

		boolean b1 = Character.isUnicodeIdentifierStart(ch1);  
		boolean b2 = Character.isUnicodeIdentifierStart(ch2);  
		boolean b3 = Character.isUnicodeIdentifierStart(ch3);  
		boolean b4 = Character.isUnicodeIdentifierStart(ch4);  
		boolean b5 = Character.isUnicodeIdentifierStart(ch5);  

		System.out.println(ch1 +" is a start Unicode identifier??:  "+b1);  
		System.out.println(ch2 +" is a start Unicode identifier??:  "+b2);  
		System.out.println(ch3 +" is a start Unicode identifier??:  "+b3);  
		System.out.println(ch4 +" is a start Unicode identifier?? : "+b4);  
		System.out.println(ch5 +" is a start Unicode identifier??:  "+b5);  
	}  
} 


0 is a start Unicode identifier??: false
d is a start Unicode identifier??: true
D is a start Unicode identifier??: true
$ is a start Unicode identifier?? : false
_ is a start Unicode identifier??: false

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.isUnicodeIdentifierStart(ch);
			System.out.println(ch + " is a start Unicode identifier??: "+b);
		}
		catch(Exception e)
		{
			System.out.println("Invalid Input!!");
		}
	}  
}


Enter the character: 2
2 is a start Unicode identifier??: false
********************************************
Enter the character: G
G is a start 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.