Java - Character isBmpCodePoint() Method



The Java Character isBmpCodePoint() method is used to check whether the code point argument accepted by this method is a BMP code point or not.

The BMP code points are ordinary code points present in the Basic Multilingual Plane. This plane contains the characters of almost all modern languages and a lot of symbol characters. The range of these BMP code points starts from 0 to 65535 (or U+0000 to U+FFFF).

These characters are represented only using a single char value, unlike supplementary code points.

Syntax

Following is the syntax of the Java Character isBmpCodePoint() method.

public static boolean isBmpCodePoint(int codePoint)

Parameters

  • codePoint − A Unicode code point value that is to be tested.

Return Value

The method returns true if the code point argument is in the range of MAX_VALUE to MIN_VALUE, and returns false otherwise.

Checking a CodePoint to be an BMP Code Point Example

The following example shows the usage of Java Character isBmpCodePoint() method. We've created an int variable and assigned it a codepoint value. Now using isBmpCodePoint() method, we're checking if the int value represents a BMP CodePoint or not.

package com.tutorialspoint;

public class isBmpCodePointDemo {
   public static void main(String args[]) {     
      int cp;
      Boolean b;
      cp = 0x0127;
      b = Character.isBmpCodePoint(cp);
      System.out.println("Is the code point BMP Code point? " + b);
   }
}

Output

If we compile and run the given program above, the output is displayed as follows −

Is the code point BMP Code point? True

Checking a CodePoint to be an BMP Code Point Example

The following example shows the usage of Java Character isBmpCodePoint() method. We've created an int variable and assigned it a codepoint value. Now using isBmpCodePoint() method, we're checking if the int value represents a BMP CodePoint or not.

Suppose, if the code point argument passed to the method is a supplementary code point, the return value would be false.

package com.tutorialspoint;

public class isBmpCodePointDemo {
   public static void main(String args[]) {      
      int cp;
      Boolean b;
      cp = 0x10ffff;
      b = Character.isBmpCodePoint(cp);
      System.out.println("Is the code point BMP Code point? " + b);
   }
}

Output

Compile and run the program above, the output will be produced as follows −

Is the code point BMP Code point? False

Checking a CodePoint to be an BMP Code Point Example

Now, let us try to apply the usage of conditional statements with the method as the return type of this method is Boolean. If true, a positive statement is set to be printed; otherwise, negative.

package com.tutorialspoint;

public class isBmpCodePointDemo {
   public static void main(String args[]) {      
      int cp;
      Boolean b;
      cp = 0x8713;
      b = Character.isBmpCodePoint(cp);
      if(b)
         System.out.println("The given code point is a BMP Code Point");
      else
         System.out.println("The given code point is not a BMP Code Point");
   }
}

Output

Once we compile and run the program above, the output is as follows −

The given code point is a BMP Code Point
java_lang_character.htm
Advertisements