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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。