Character getType() Method in Java with examples Last Updated : 12 Apr, 2023 Comments Improve Suggest changes Like Article Like Report The Character.getType(char ch) is an inbuilt method in java that returns a value indicating a character’s general category. This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the getType(int) method. Syntax:public static int getType(char ch)Parameters: The method accepts one parameter ch of character datatype which refers to the character to be tested. Return value: This method returns a value of type integer representing the character's general category. Below programs illustrates the use of Character.getType(char ch) method: Program 1: Java import java.lang.*; public class gfg { public static void main(String[] args) { // Create 2 character primitives ch1, ch2 and assigning values char c1 = 'K', c2 = '%'; // Assign getType values of c1, c2 to int primitives int1, int2 int int1 = Character.getType(c1); int int2 = Character.getType(c2); String str1 = "Category of " + c1 + " is " + int1; String str2 = "Category of " + c2 + " is " + int2; System.out.println( str1 ); System.out.println( str2 ); } } Output:Category of K is 1 Category of % is 24Program 2: Java import java.lang.*; public class gfg { public static void main(String[] args) { // Create 2 character primitives ch1, ch2 and assigning values char c1 = 'T', c2 = '^'; // Assign getType values of c1, c2 to int primitives int1, int2 int int1 = Character.getType(c1); int int2 = Character.getType(c2); String str1 = "Category of " + c1 + " is " + int1; String str2 = "Category of " + c2 + " is " + int2; System.out.println(str1); System.out.println(str2); } } Output:Category of T is 1 Category of ^ is 27The java.lang.Character getType(int codePoint) is similar to previous method in all the manner, this method can handle supplementary characters. Syntax:public static int getType(int codePoint)Parameter: The method accepts a single parameter codePoint of integer datatype and refers to the character (Unicode code point) to be tested. Return Value: This method returns a value of type int representing the character's general category. Below programs demonstrates the above mentioned method: Program 1: Java // Java program to demonstrate // the above method import java.lang.*; public class gfg { public static void main(String[] args) { // int primitives c1, c2 int c1 = 0x0037, c2 = 0x016f; // Assign getType values of c1, c2 to int primitives int1, int2 int int1 = Character.getType(c1); int int2 = Character.getType(c2); // Print int1, int2 values System.out.println( "Category of c1 is " + int1); System.out.println( "Category of c1 is " + int2); } } Output:Category of c1 is 9 Category of c1 is 2Program 2: Java // Java program to demonstrate // the above method import java.lang.*; public class gfg { public static void main(String[] args) { // int primitives c1, c2 int c1 = 0x0135, c2 = 0x015f; // Assign getType values of c1, c2 to int primitives int1, int2 int int1 = Character.getType(c1); int int2 = Character.getType(c2); // Print int1, int2 values System.out.println( "Category of c1 is " + int1); System.out.println( "Category of c1 is " + int2); } } Output:Category of c1 is 2 Category of c1 is 2 Comment More infoAdvertise with us Next Article Character getType() Method in Java with examples T Twinkl Bajaj Follow Improve Article Tags : Misc Java Java-lang package Java-Functions Practice Tags : JavaMisc Similar Reads Class getTypeName() method in Java with Examples The getTypeName() method of java.lang.Class class is used to get the type name of this class, which provides the information about this class' type. The method returns the type name of this class in the form of String. Syntax: public String getTypeName() Parameter: This method does not accept any pa 2 min read Character isDigit() method in Java with examples The java.lang.Character.isDigit(char ch) is an inbuilt method in java which determines whether a specified character is a digit or not. There are few conditions that a character must accomplish to be accepted as a digit. That is if the general category type of a character, provided by Character.getT 4 min read Field getType() method in Java with Examples The getType() method of java.lang.reflect.Field used to get the declared type of the field represented by this Field object.This method returns a Class object that identifies the declared type Syntax: public String getType() Parameters: This method accepts nothing. Return value: This method returns 2 min read CharacterIterator first() method in Java with Examples The first() method of java.text.CharacterIterator interface in Java is used to get the character at the beginning of this CharacterIterator. This method sets the position of the iterator to the first character, using getBeginIndex(), and then returns that character. Syntax: public char first() Param 1 min read Constructor getTypeParameters() method in Java with Examples The getTypeParameters() method of a Constructor class is used to get an array of TypeVariable objects declared by this Constructor Object, in declaration order. Elements of array represent the type variables objects declared by Method. An array of length 0 is returned by this getTypeParameters(), if 2 min read Class getTypeParameters() method in Java with Examples The getTypeParameters() method of java.lang.Class class is used to get the type parameters of this entity. This entity can be a class, an array, an interface, etc. The method returns an array of TypeVariable objects representing the type variables.Syntax: public TypeVariable<Class<T>> ge 2 min read Class getComponentType() method in Java with Examples The getComponentType() method of java.lang.Class class is used to get the Class representing the component type of an array, if this class represents one. Else it returns null.Syntax: public Class getComponentType() Parameter: This method does not accept any parameter.Return Value: This method retur 2 min read CharBuffer charAt() methods in Java with Examples The charAt() method of java.nio.CharBuffer Class is used to read the character at the given index relative to the current position. Syntax: public final char charAt(int index) Parameters: This method takes the index of the character to be read, relative to the position; must be non-negative and smal 2 min read KeyStore getType() method in Java with Examples The getType() method of java.security.KeyStore class is used to get the type of this keystore. Syntax: public final String getType() Parameter: This method accepts nothing as a parameter. Return Value: This method returns the type of this keystore. Note: All the programs in this article wonât run on 3 min read CharacterIterator next() method in Java with Examples The next() method of java.text.CharacterIterator interface in Java is used to get the next character that is to be read by this CharacterIterator. This method decrements this iterator to one index forward and returns that next character. Syntax: public char next() Parameter: This method do not accep 1 min read Like