Character.isTitleCase() in Java

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

Approach 1: When the argument is of type char.

Syntax:

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

This method takes one argument of type char as its parameter. This method determines if the specified character is a title case character.

Parameters: One parameter is required for this method.

ch: the character to be tested.

Returns: true if the character is a title case; false otherwise.

Exceptions: NA

Java

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

        char ch = 'A';
        System.out.println(Character.isTitleCase(ch));
    }
}

Output:

false


Approach 2: When the argument is of type int.

Syntax:

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

This method takes one argument of type int as its parameter. This method determines if the specified character (Unicode code point) is a titlecase character.

Parameters: One parameter is required for this method.

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

Returns: true if the character is titlecase; false otherwise.

Exceptions: NA

Java

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

        int codePoint = 'B';
        System.out.println(Character.isTitleCase(codePoint));
    }
}

Output:

false

No comments:

Post a Comment