Character.isMirrored(int codePoint)是Java中的一个内置方法,该方法确定是否根据Unicode规范对指定字符(Unicode代码点)进行镜像。当以从右到左的文本显示时,镜像字符的字形应水平镜像。例如,“ \ u0028”左括号在语义上被定义为左括号。这将在从左到右的文本中显示为“(”,但在从右到左的文本中显示为“)”。
用法:
public static boolean isMirrored(int codePoint)
参数:整数类型的参数codePoint是要测试的字符(Unicode代码点)。
返回值:如果字符已镜像,则此方法返回true;如果字符未镜像或未定义,则返回false。
以下示例程序旨在说明Character.isMirrored()方法:
示例1:
// Code to illustrate the isMirrored() method
import java.lang.*;
public class gfg {
public static void main(String[] args)
{
// Creating 2 int primitives char1, char2
int char1 = 0x0c05, char2 = 0x013c;
// Checks if character is mirrored or not and prints
boolean bool1 = Character.isMirrored(char1);
String str1 = "char1 represents a mirrored character is " + bool1;
System.out.println(str1);
boolean bool2 = Character.isMirrored(char2);
String str2 = "char2 represents a mirrored character is " + bool2;
System.out.println(str2);
}
}
输出:
char1 represents a mirrored character is false char2 represents a mirrored character is false
示例2:
// Code to illustrate the isMirrored() method
import java.lang.*;
public class gfg {
public static void main(String[] args)
{
// Create 2 int primitives c1, c2
int c1 = 0x0c07, c2 = 0x063c;
// Checks if character is mirrored or not and prints
boolean bool1 = Character.isMirrored(c1);
String str1 = "c1 represents a mirrored character is " + bool1;
System.out.println(str1);
boolean bool2 = Character.isMirrored(c2);
String str2 = "c2 represents a mirrored character is " + bool2;
System.out.println(str2);
}
}
输出:
c1 represents a mirrored character is false c2 represents a mirrored character is false
参考:https://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isMirrored(int)
相关用法
- Java Java lang.Long.numberOfLeadingZeros()用法及代码示例
- Java Java.util.Collections.rotate()用法及代码示例
- Java Java lang.Long.highestOneBit()用法及代码示例
- Java Java lang.Long.byteValue()用法及代码示例
- Java Java lang.Long.numberOfTrailingZeros()用法及代码示例
- Java Java lang.Long.lowestOneBit()用法及代码示例
- Java Java lang.Long.reverse()用法及代码示例
- Java Java lang.Long.builtcount()用法及代码示例
- Java Java.util.Collections.disjoint()用法及代码示例
- Java Java.math.BigInteger.modInverse()用法及代码示例
- Java Clock tickMinutes()用法及代码示例
- Java Java.math.BigInteger.probablePrime()用法及代码示例
- Java Java.util.ArrayList.addall()用法及代码示例
注:本文由纯净天空筛选整理自Twinkl Bajaj大神的英文原创作品 Character.isMirrored() method in Java。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。