當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Java Character isBmpCodePoint()用法及代碼示例


Character類的isBmpCodePoint(int codePoint()方法一般判斷給定(或指定)的Unicode字符是否在Basic Multilingual Plane(BMP)的範圍內,這些指定的codePoints可以通過單個char值來表示。

用法

public static Boolean isBmpCodePoint(int codePoint)

參數

上述方法隻需要一個參數:

a.)codePoint 是需要測試的 Unicode 字符。

返回值

Character 類的 isBmpCodePoint(int codePoint) 方法返回布爾值,即 true,如果指定的 codePoint 位於 MIN_VALUE 和 MAX_VALUE 的值之間。否則,它返回 false。

例子1

public class JavaCharcterisBmpCodePointExample1 {
public static void main(String[] args) {     	
	char cp1 = ' ';
	char cp2 = 'A';
	char cp3 = 'B';
	char cp4 = 'a';
	char cp5 = 'b';
    boolean b1 = Character.isBmpCodePoint(cp1);
    boolean b2 = Character.isBmpCodePoint(cp2);
    boolean b3 = Character.isBmpCodePoint(cp3);
    boolean b4 = Character.isBmpCodePoint(cp4);
    boolean b5 = Character.isBmpCodePoint(cp5);
    System.err.println("The value for the first char comes to be: "+b1);
    System.err.println("The value for the second char comes to be:"+b2);
    System.err.println("The value for the third char comes to be: "+b3);
    System.err.println("The value for the fourth char comes to be:"+b4);
    System.err.println("The value for the fifth char comes to be: "
    +b5);
  }
}

輸出:

The value for the first char comes to be: true
The value for the second char comes to be:true
The value for the third char comes to be: true
The value for the fourth char comes to be:true
The value for the fifth char comes to be: true

例子2

public class JavaCharcterisBmpCodePointExample2 {
public static void main(String[] args) {	
   // Initialize the codePoints.
         int codepoint1 = 12;
	  int codepoint2 = 121;
	  int codepoint3 = 684748;	
  // Check the codepoints whether they are in Basic Multilingual Plane (BMP).
	  boolean result1 = Character.isBmpCodePoint(codepoint1);
	  boolean result2 = Character.isBmpCodePoint(codepoint2);
	  boolean result3 = Character.isBmpCodePoint(codepoint3);
 // Finally print the result.
System.out.println("The boolean value for the first codePoint is given as: "+result1);
System.out.println("The boolean value for the second codePoint is given as: "+result2);	
System.out.println("The boolean value for the third codePoint is given as: "+result3);	
	}
}

輸出:

The boolean value for the first codePoint is given as: true
The boolean value for the second codePoint is given as: true
The boolean value for the third codePoint is given as: false

例子3

public class JavaCharcterisBmpCodePointExample3 {
public static void main(String[] args) {     	
	char cp1 = '1';
	char cp2 = '2';
	char cp3 = '3';
	char cp4 = '4';
	char cp5 = '5';
    boolean b1 = Character.isBmpCodePoint(cp1);
    boolean b2 = Character.isBmpCodePoint(cp2);
    boolean b3 = Character.isBmpCodePoint(cp3);
    boolean b4 = Character.isBmpCodePoint(cp4);
    boolean b5 = Character.isBmpCodePoint(cp5);
    System.err.println("The value for the first char comes to be: "+b1);
    System.err.println("The value for the second char comes to be:"+b2);
    System.err.println("The value for the third char comes to be: "+b3);
    System.err.println("The value for the fourth char comes to be:"+b4);
    System.err.println("The value for the fifth char comes to be: "+b5);
  }
}

輸出:

The value for the first char comes to be: true
The value for the second char comes to be:true
The value for the third char comes to be: true
The value for the fourth char comes to be:true
The value for the fifth char comes to be: true



相關用法


注:本文由純淨天空篩選整理自 Java Character isBmpCodePoint() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。