Character.isJavaIdentifierPart() in Java

Character.isJavaIdentifierPart(): This method is available in java.lang.Character class of Java.

Approach 1: When the argument of type char.

Syntax:

 boolean java.lang.Character.isJavaIdentifierPart(char ch)

This method takes one argument of type char as its parameter. This method determines if the specified character may be part of a Java identifier as other than the first character.

Note:

1. It is a letter.

2. It is a currency symbol (such as '$').

3. It is a connecting punctuation character (such as '_').

4. It  is a digit.

5. It is a numeric letter (such as a Roman numeral character).

6. It is a combining mark.

7. It is a non-spacing mark.

Parameters: One parameter is required for this method.

ch: the character to be tested.

Returns: true if the character may be part of a Java identifier; false otherwise.

Exceptions: NA

Java

public class CharacterisJavaIdentifierPartchar {
    public static void main(String[] args) {

        char ch = 'a';
        System.out.println(Character.isJavaIdentifierPart(ch));
    }
}

Output:

true


Approach 2: When the argument of type int.

Syntax:

boolean java.lang.Character.isJavaIdentifierPart(int codePoint)

This method takes one argument of type in as its parameter. This method determines if the character (Unicode code point) may be part of a Java identifier as other than the first character.

Note:

1. It is a letter.

2. It is a currency symbol (such as '$').

3. It is a connecting punctuation character (such as '_').

4. It is a digit.

5. It is a numeric letter (such as a Roman numeral character).

6. It is a combining mark.

7. It is a non-spacing mark.

Parameters: One parameter is required for this method.

codePoint: the character (Unicode code point) to be tested.

Returns: true if the character may be part of a Java identifier; false otherwise.

Exceptions: NA

Java

public class CharacterisJavaIdentifierPartint {
    public static void main(String[] args) {

        int codePoint = '$';
        System.out.println(Character.isJavaIdentifierPart(codePoint));
    }
}

Output:

true

No comments:

Post a Comment