java.lang.Character isSurrogate(char ch)


The Character.isSurrogate(char ch) java method determines if the given char value is a Unicode surrogate code unit. Such values do not represent characters by themselves, but are used in the representation of supplementary characters in the UTF-16 encoding.

A char value is a surrogate code unit if and only if it is either a low-surrogate code unit or a high-surrogate code unit.

The isSurrogate(char ch) method of Character class is static thus it should be accessed statically which means the we would be calling this method in this format:

Character.isSurrogate(char ch)

Non static method is usually called by just declaring method_name(argument) however in this case since the method is static, it should be called by appending the class name as suffix. We will be encountering a compilation problem if we call the java isSurrogate() method non statically.

Method Syntax

public static boolean isSurrogate(char ch)

Method Argument

Data Type Parameter Description
char ch the char value to be tested.

Method Returns

The isSurrogate(char ch) method of Character class returns true if the char value is between MIN_SURROGATE and MAX_SURROGATE inclusive; false otherwise.


Requires Java 1.7 and up

Java Character isSurrogate(char ch) Example

Below is a simple java example on the usage of isSurrogate(char ch) method of Character class.


 * This example source code demonstrates the use of 
 * isSurrogate(char ch) method of Character class.

public class CharacterIsSurrogateExample {

	public static void main(String[] args) {
		 * Editors Note:
		 * Range is ud800 to udfff
		// initialize characters to be tested
		char c1 = 'udd10';
		char c2 = 'uf000';
		// check the characters if it is a Unicode surrogate code unit
		boolean result1 = Character.isSurrogate(c1);
		boolean result2 = Character.isSurrogate(c2);
		// print the result
		System.out.println("is c1 a Unicode surrogate code unit?"+result1);
		System.out.println("is c2 a Unicode surrogate code unit?"+result2);



Sample Output

Below is the sample output when you run the above example.

java Character isSurrogate(char ch) example output