java.lang.Character getDirectionality(char ch)


The Character.getDirectionality(char ch) java method returns the Unicode directionality property for the given character. Character directionality is used to calculate the visual ordering of text. The directionality value of undefined char values is DIRECTIONALITY_UNDEFINED.

This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the getDirectionality(int) method.

The getDirectionality(char ch) 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.digit(char ch, int radix)

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 getDirectionality() method non statically.

Method Syntax

public static byte getDirectionality(char ch)

Method Argument

Data Type Parameter Description
char ch char for which the directionality property is requested.

Method Returns

The getDirectionality(char ch) method of Character class returns byte which denotes the directionality property of the char value.


Requires Java 1.4 and up

Java Character getDirectionality(char ch) Example

Below is a simple java example on the usage of getDirectionality(char ch) method of Character class.


import java.util.Scanner;

 * This example source code demonstrates the use of 
 * getDirectionality(char ch) method of Character class.

public class CharacterGetDirectionalityCharExample {

	public static void main(String[] args) {

		// Ask for user input
		System.out.print("Enter an input:");

		// use scanner to get the user input
		Scanner s = new Scanner(;

		// gets the user input
		char[] value = s.nextLine().toCharArray();
		// close the scanner object

		 * byte value 0 represents DIRECTIONALITY_LEFT_TO_RIGHT
		// Unicode directionality property for the given character
		for (char ch : value) {
			byte result = Character.getDirectionality(ch);
			// print the result
			System.out.println("character " + ch
					+ " Unicode directionality property is " + result);

		// check in Character constant for equivalent


Sample Output

Below is the sample output when you run the above example.

java Character getDirectionality(char ch) example output