The java.lang.Character.isJavaIdentifierStart(char ch) is an inbuilt method in java which determines if the specified character is permissible as the first character in a Java identifier or not. A character may start as a Java identifier if and only if one of the following conditions is true:
- isLetter(ch) returns true
- getType(ch) returns LETTER_NUMBER
- ch is a currency symbol (such as ‘$’)
- ch is a connecting punctuation character (such as ‘_’).
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the isJavaIdentifierStart(int) method.
public static boolean isJavaIdentifierStart(char ch)
Parameters: The function accepts one mandatory parameter ch which specifies the character to be tested.
Return value: This method returns a boolean value. The boolean value is True if the character may start a Java identifier, False otherwise.
Program below demonstrates the Character.isJavaIdentifierStart(char ch) method:
9 may start a Java identifier is : false - may start a Java identifier is : false
5 may start a Java identifier is : false _ may start a Java identifier is : true
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.