Character.isMirrored() in Java with examples
Last Updated :
13 Jun, 2018
java.lang.Character.isMirrored() is an inbuilt method in java that determines whether the character is mirrored according to the Unicode specification. Mirrored characters should have their glyphs horizontally mirrored when displayed in text that is right-to-left. For example, ‘\u0028’ LEFT PARENTHESIS is semantically defined to be an opening parenthesis. This will appear as a “(” in text that is left-to-right but as a “)” in text that is right-to-left. Some examples of mirrored characters are [ ] { } ( ) etc.
Syntax:
public static boolean isMirrored(char ch)
Parameters:
ch - char for which the mirrored property is requested
Returns: This method returns true if the char is mirrored else it returns false if the character is not mirrored or undefined.
Given below is the illustration of Character.isMirrored() method:
Program 1:
import java.lang.*;
public class gfg {
public static void main(String[] args)
{
char ch1 = '[' ;
char ch2 = '+' ;
char ch3 = '}' ;
char ch4 = '(' ;
boolean b1 = Character.isMirrored(ch1);
System.out.println(ch1 + " is a mirrored character is " + b1);
boolean b2 = Character.isMirrored(ch2);
System.out.println(ch2 + " is a mirrored character is " + b2);
boolean b3 = Character.isMirrored(ch1);
System.out.println(ch3 + " is a mirrored character is " + b3);
boolean b4 = Character.isMirrored(ch2);
System.out.println(ch4 + " is a mirrored character is " + b4);
}
}
|
Output:
[ is a mirrored character is true
+ is a mirrored character is false
} is a mirrored character is true
( is a mirrored character is false
Program 2:
import java.lang.*;
public class gfg {
public static void main(String[] args)
{
char ch1 = '4' ;
char ch2 = '0' ;
boolean b1 = Character.isMirrored(ch1);
System.out.println(ch1 + " is a mirrored character is " + b1);
boolean b2 = Character.isMirrored(ch2);
System.out.println(ch2 + " is a mirrored character is " + b2);
}
}
|
Output:
4 is a mirrored character is false
0 is a mirrored character is false
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...