LAST UPDATED: NOVEMBER 6, 2020
Java Character isBmpCodePoint() Method
Java isBmpCodePoint()
method is a part of Character
class. This method is used to determine whether the specified Unicode codepoint character is a part of the range of Basic Multilingual Plane(BMP).
It must be noted that the specified Unicode codePoints can be represented with a single char value.
Syntax:
public static Boolean isBmpCodePoint(int codePoint)
Parameters:
The parameter passed is the Unicode codepoint character which is to be checked whether it lies in BMP or not.
Returns:
Returns boolean value true
if the specified codepoint is between MIN_VALUE
and MAX_VALUE
inclusive range else returns false
.
Example 1:
Here, the Unicode codepoint values are checked whether they lie in BMP or not.
public class StudyTonight
{
public static void main(String[] args)
{
int cp1 = 78;
int cp2 = 48;
int cp3 = 90;
int cp4 = 34;
int cp5 = -67;
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.out.println("The value for " + (char) cp1 + " is : " + b1);
System.out.println("The value for " + (char) cp2 + " is : " + b2);
System.out.println("The value for " + (char) cp3 + " is : " + b3);
System.out.println("The value for " + (char) cp4 + " is : " + b4);
System.out.println("The value for " + (char) cp5 + " is : " + b5);
}
}
The value for N is : true
The value for 0 is : true
The value for Z is : true
The value for " is : true
The value for ? is : false
Example 2:
Here is a user-defined example where anyone using this code can put a value of his choice and get the equivalent output.
import java.util.Scanner;
public class StudyTonight
{
public static void main(String[] args)
{
try
{
System.out.print("Enter the unicode codepoint: ");
Scanner sc = new Scanner(System. in );
int i = sc.nextInt();
boolean b = Character.isBmpCodePoint(i);
System.out.println("The value for " + (char) i + " is :" + b);
}
catch(Exception e)
{
System.out.println("Invalid Input!!");
}
}
}
Enter the unicode codepoint: -22
The value for ? is :false
*****************************************
Enter the unicode codepoint: 76
The value for L is :true
Live Example:
Here, you can test the live code example. You can execute the example for different values, even can edit and write your examples to test the Java code.