Signup/Sign In

Java Character isSupplementaryCodePoint() Method

Java isSupplementaryCodePoint() is a part of Character class. This method is used to check whether the specified Unicode codepoint character is in the supplementary character range or not.

Supplementary characters are characters with code points in the range U+10000 to U+10FFFF, that is, those characters that could not be represented in the original 16-bit design of Unicode.

Syntax:

public static boolean isSupplementaryCodePoint(int codePoint)

Parameters:

The parameter passed is the Unicode codepoint character to be checked whether it lies in the supplementary character range or not.

Returns:

Returns the boolean value true if the specified Unicode codepoint character lies in supplementary character range else return false.

Example 1:

Here, the characters are checked whether they lie in the supplementary character range or not.

public class StudyTonight
{  
	public static void main(String[] args)
	{  
		int cp1 = 67;  
		int cp2 = 75567;  
		int cp3 = 119;  
		int cp4 = 93;   
		int cp5 = 65545;  

		boolean b1 = Character.isSupplementaryCodePoint(cp1);  
		boolean b2 = Character.isSupplementaryCodePoint(cp2);  
		boolean b3 = Character.isSupplementaryCodePoint(cp3);  
		boolean b4 = Character.isSupplementaryCodePoint(cp4);  
		boolean b5 = Character.isSupplementaryCodePoint(cp5);  

		System.out.println((char)cp1 +" is in supplentary character range??:  "+b1);  
		System.out.println((char)cp2 +" is in supplentary character range??:  "+b2);  
		System.out.println((char)cp3 +" is in supplentary character range??:  "+b3);  
		System.out.println((char)cp4 +" is in supplentary character range??:  "+b4);  
		System.out.println((char)cp5 +" is in supplentary character range??:  "+b5);  
	}  
} 


C is in supplentary character range??: false
? is in supplentary character range??: true
w is in supplentary character range??: false
] is in supplentary character range??: false
is in supplentary character range??: true

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 character: ");  
			Scanner sc = new Scanner(System.in);        
			int cp = sc.nextInt(); 
			boolean b = Character.isSupplementaryCodePoint(cp);
			System.out.println((char)cp + " is in supplentary range?: "+b);
		}
		catch(Exception e)
		{
			System.out.println("Invalid Input!!");
		}
	}  
}


Enter the Unicode character: 76776
? is in supplentary range?: true
*******************************************
Enter the Unicode character: 1212
? is in supplentary range?: false

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.



About the author:
A Computer Science and Engineering Graduate(2016-2020) from JSSATE Noida. JAVA is Love. Sincerely Followed Sachin Tendulkar as a child, M S Dhoni as a teenager, and Virat Kohli as an adult.