Javatpoint Logo
Javatpoint Logo

Java Character getType(char ch) Method

The getType(char ch) method of Character class returns a value which indicates the general category of the character. This method is not used for the supplementary characters. We can use the getType(int codePoint) method to support all the Unicode characters including the supplementary.

Syntax

Parameter

ch: The character which needs to be tested.

Return Value

This method returns a value which is of the type int representing the general category of the character.

Example 1

Test it Now

Output:

The integer value for the character 2 is given as:
9
The integer value for the character { is given as:
21
The integer value for the character * is given as:
24
The integer value for the character @ is given as:
24
The integer value for the character $ is given as:
26

Example 2

Test it Now

Output:

Enter the first input of your choice:{
The general category for the character { is given as: 21
Enter the second input of your choice:&
The general category for the character & is given as: 24

Example 3

Test it Now

Output:

The general category of character 1 is: 9
The general category of character ! is: 24
The general category of character ) is: 22

Java Character getType(int codePoint) Method

The getType(int codePoint) method of Character class generally returns the value which indicates the general category of the character.

Syntax

Parameter

codePoint: The character(Unicode codePoint) which needs to be tested.

Return Value

The getType(int codePoint) method returns the integer type value that represents the general category of the character.

Example 4

Test it Now

Output:

The general category for the character X is given as: 1
The general category for the character n is given as: 2

Example 5

Test it Now

Output:

The general category of the first character is given as: 24
The general category of the second character is given as: 2
Next TopicJava Character



Help Others, Please Share

facebook twitter pinterest