- Java.lang Package classes
- Java.lang - Home
- Java.lang - Boolean
- Java.lang - Byte
- Java.lang - Character
- Java.lang - Character.Subset
- Java.lang - Character.UnicodeBlock
- Java.lang - Class
- Java.lang - ClassLoader
- Java.lang - Compiler
- Java.lang - Double
- Java.lang - Enum
- Java.lang - Float
- Java.lang - InheritableThreadLocal
- Java.lang - Integer
- Java.lang - Long
- Java.lang - Math
- Java.lang - Number
- Java.lang - Object
- Java.lang - Package
- Java.lang - Process
- Java.lang - ProcessBuilder
- Java.lang - Runtime
- Java.lang - RuntimePermission
- Java.lang - SecurityManager
- Java.lang - Short
- Java.lang - StackTraceElement
- Java.lang - StrictMath
- Java.lang - String
- Java.lang - StringBuffer
- Java.lang - StringBuilder
- Java.lang - System
- Java.lang - Thread
- Java.lang - ThreadGroup
- Java.lang - ThreadLocal
- Java.lang - Throwable
- Java.lang - Void
- Java.lang Package extras
- Java.lang - Interfaces
- Java.lang - Errors
- Java.lang - Exceptions
- Java.lang Package Useful Resources
- Java.lang - Useful Resources
- Java.lang - Discussion
Java - Character isSupplementaryCodePoint() Method
The Java Character isSupplementaryCodePoint() method determines whether the specified character (Unicode code point) is in the supplementary character range. The supplementary character range in the Unicode system falls in U+10000 to U+10FFFF.
The Unicode code points are divided into two categories − Basic Multilingual Plane (BMP) code points and Supplementary code points. BMP code points are present in the range U+0000 to U+FFFF.
Whereas, supplementary characters are rare characters that are not represented using the original 16-bit Unicode. For example, these type of characters are used in Chinese or Japanese scripts and hence, are required by the applications used in these countries.
Syntax
Following is the syntax for Java Character isSupplementaryCodePoint() method
public static boolean isSupplementaryCodePoint(int codePoint)
Parameters
codePoint − the Unicode code point to be tested
Return Value
This method returns true if the specified code point falls in the range of supplementary code points (MIN_SUPPLEMENTARY_CODE_POINT to MAX_CODE_POINT inclusive), false otherwise.
Example
The following example shows the usage of Java Character isSupplementaryCodePoint() method.
package com.tutorialspoint; import java.lang.*; public class CharacterDemo { public static void main(String[] args) { // create 2 int primitives cp1, cp2 int cp1, cp2; // assign values to cp1, cp2 cp1 = 0x10ffd; cp2 = 0x004ca; // create 2 boolean primitives b1, b2 boolean b1, b2; /** * check if cp1, cp2 are in supplementary character range * and assign results to b1, b2 */ b1 = Character.isSupplementaryCodePoint(cp1); b2 = Character.isSupplementaryCodePoint(cp2); String str1 = "cp1 represents a supplementary code point is " + b1; String str2 = "cp2 represents a supplementary code point is " + b2; // print b1, b2 values System.out.println( str1 ); System.out.println( str2 ); } }
Output
Let us compile and run the above program, this will produce the following result −
cp1 represents a supplementary code point is true cp2 represents a supplementary code point is false
Example
Since the method returns a boolean value, we can also use this method as a condition to the conditional statements in Java (if – else).
import java.lang.*; public class Demo{ public static void main(String []args){ int cp = 0x10023; if(Character.isSupplementaryCodePoint(cp)) System.out.println("The character is a supplementary character"); else System.out.println("The character is not a supplementary character"); } }
Output
Once the program is compiled and executed, the output is displayed as following −
The character is a supplementary character
Example
In addition to the conditional statements, we can use loop statements on an integer array containing code points. We use loop statements to traverse through the array and then, in conditional statements, the method is used as a condition for each code point to check whether they are supplementary characters or not.
import java.lang.*; public class CharacterDemo { public static void main(String []args){ int cp[] = new int[] {0x6718, 0x10034, 0x10fff, 0x07821, 0x3468}; for(int i = 0; i < cp.length; i++) { if(Character.isSupplementaryCodePoint(cp[i])) System.out.println("The character is a supplementary character"); else System.out.println("The character is not a supplementary character"); } } }
Output
The output is achieved after compiling and executing the program as follows −
The character is not a supplementary character The character is a supplementary character The character is a supplementary character The character is not a supplementary character The character is not a supplementary character