java.lang.Character getType(int codePoint)
Description
The getType(int codePoint) method of Character class is static thus it should be accessed statically which means the we would be calling this method in this format:
Character.getType(int codePoint)
Non static method is usually called by just declaring method_name(argument) however in this case since the method is static, it should be called by appending the class name as suffix. We will be encountering a compilation problem if we call the java getType() method non statically.
Method Syntax
public static int getType(int codePoint))
Method Argument
Data Type | Parameter | Description |
---|---|---|
int | codePoint | the character (Unicode code point) to be tested. |
Method Returns
The getType(int codePoint) method of Character class returns a value of type int representing the character’s general category.
Compatibility
Requires Java 1.5 and up
Java Character getType(int codePoint) Example
Below is a simple java example on the usage of getType(int codePoint) method of Character class.
package com.javatutorialhq.java.examples; /* * This example source code demonstrates the use of * getType(int codePoint) method of Character class. */ public class CharacterGetTypeCodepointExample { public static void main(String[] args) { // initialize a codepoint int codepoint = 65; // convert codepoint to char char ch = (char) codepoint; // get a value indicating a character's general category int result = Character.getType(codepoint); // print the result System.out.println("character " + ch + " general category is " + result); // please refer to Character constants } }
Sample Output
Below is the sample output when you run the above example.