java.lang.Character isJavaIdentifierStart(int codePoint)

Description

The Character.isJavaIdentifierStart(int codePoint) java method determines if the character (Unicode code point) is permissible as the first character in a Java identifier.

A character may start 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 ‘_’).

The isJavaIdentifierStart(int codePoint) method of Character class is static thus it should be accessed statically which means the we would be calling this method in this format:

Character.isJavaIdentifierStart(int codePoint)

Non static method is usually called by just declaring method_name(argument) however in this case since the method is static, it should be called by appending the class name as suffix. We will be encountering a compilation problem if we call the java isJavaIdentifierStart() method non statically.

Method Syntax

public static boolean isJavaIdentifierStart(int codePoint)

Method Argument

Data Type Parameter Description
int codepoint the character (Unicode code point) to be tested.

Method Returns

The isJavaIdentifierStart(int codePoint) method of Character class returns true if the character may start a Java identifier; false otherwise.

Compatibility

Requires Java 1.5 and up

Java Character isJavaIdentifierStart(int codePoint) Example

Below is a simple java example on the usage of isJavaIdentifierStart(int codePoint) method of Character class.

package com.javatutorialhq.java.examples;

/*
 * This example source code demonstrates the use of 
 * isJavaIdentifierStart(int codePoint) method of Character class.
 */

public class CharacterIsJavaIdentifierStartCodepointExample {

	public static void main(String[] args) {
		
		// initialize a codepoint
		int codepoint = 89;
		
		/*
		 * check if the codepoint is permissible as 
		 * the first character in a Java identifier
		 */		
		boolean checkBool = Character.isJavaIdentifierStart(codepoint);
		
		// print result
		if (checkBool) {
			System.out.print("Codepoint '" + codepoint + "' is permissible as "
					+ "the first character in a Java identifier");
		} else {
			System.out.print("Codepoint '" + codepoint + "' is not permissible as "
					+ "the first character in a Java identifier");
		}
		
	}

}

Sample Output

Below is the sample output when you run the above example.

java Character isJavaIdentifierStart(int codePoint) example output