Java Character getType(char ch) MethodThe 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. SyntaxParameterch: The character which needs to be tested. Return ValueThis method returns a value which is of the type int representing the general category of the character. Example 1Test it NowOutput: 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 2Test it NowOutput: 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 3Test it NowOutput: 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) MethodThe getType(int codePoint) method of Character class generally returns the value which indicates the general category of the character. SyntaxParametercodePoint: The character(Unicode codePoint) which needs to be tested. Return ValueThe getType(int codePoint) method returns the integer type value that represents the general category of the character. Example 4Test it NowOutput: The general category for the character X is given as: 1 The general category for the character n is given as: 2 Example 5Test it NowOutput: 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
|