Character.isSurrogatePair() in Java

Character.isSurrogatePair(): This method is available in java.lang.Character class of Java.

Syntax:

boolean java.lang.Character.isSurrogatePair(char high, char low)

This method takes two arguments of type char as its parameter. This method determines whether the specified pair of charvalues is a valid Unicode surrogate pair.

This method is equivalent to the expression:

isHighSurrogate(high) && isLowSurrogate(low)

Parameters: Two parameters are required for this method.

high: the high-surrogate code value to be tested.

low: the low-surrogate code value to be tested.

Returns: true if the specified high and low-surrogate code values represent a valid surrogate pair; false otherwise.

Exceptions: NA

Approach

Java

public class CharacterisSurrogatePair {
    public static void main(String[] args) {

        char high = 'm', low = 'a';
        System.out.println(Character.isSurrogatePair(high, low));
    }
}

Output:

false

No comments:

Post a Comment