The java.lang.Character.getDirectionality() is an inbuilt method in Java which 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. In order to support all the Unicode characters including supplementary characters, pass an integer in the parameter of this method.
public static byte getDirectionality(char ch)
Parameters: The function accepts one parameter ch which is mandatory. This parameter specifies the char for which the directionality property is requested. The parameter can be of int or char data type.
Return value: The function returns byte which denotes the directionality property of the char value.
Below programs illustrate the above method:
Directionality of first primitive is 13 Directionality of first primitive is 0
Directionality of first primitive is 0 Directionality of first primitive is 2
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.