A Character class is a subclass of an Object and it wraps a value of the primitive type char in an object. An object of type Character contains a single field whose type is char. We can determine the unicode category for a particular character by using the getType() method. It is a static method of Character class and it returns an integer value of char ch representing in unicode general category.
Syntax
public static int getType(char ch)
Example
public class CharacterTypeTest { public static void main(String args[]) { System.out.println("T represnts unicode category of: " + Character.getType('T')); System.out.println("@ represnts unicode category of: " + Character.getType('@')); System.out.println(") represnts unicode category of: " + Character.getType(')')); System.out.println("1 represnts unicode category of: " + Character.getType('1')); System.out.println("- represnts unicode category of: " + Character.getType('-')); System.out.println("_ represnts unicode category of: " + Character.getType('_')); System.out.println("a represnts unicode category of: " + Character.getType('a')); } }
Output
T represnts unicode category of: 1 @ represnts unicode category of: 24 ) represnts unicode category of: 22 1 represnts unicode category of: 9 - represnts unicode category of: 20 _ represnts unicode category of: 23 a represnts unicode category of: 2