java.lang.Character isSurrogatePair(char high, char low)
Description
The isSurrogatePair(char high, char low) 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.isSurrogatePair(char high, char low)
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 isSurrogatePair() method non statically.
Method Syntax
public static boolean isSurrogatePair(char high, char low)
Method Argument
Data Type | Parameter | Description |
---|---|---|
char | high | the high-surrogate code value to be tested |
char | low | the low-surrogate code value to be tested |
Method Returns
The isSurrogatePair(char high, char low) method of Character class returns true if the specified high and low-surrogate code values represent a valid surrogate pair; false otherwise.
Compatibility
Requires Java 1.5 and up
Java Character isSurrogatePair(char high, char low) Example
Below is a simple java example on the usage of isSurrogatePair(char high, char low) method of Character class.
package com.javatutorialhq.java.examples; /* * This example source code demonstrates the use of * isSurrogatePair(char high, char low) method of Character class. */ public class CharacterIsSurrogatePairExample { public static void main(String[] args) { // initialize characters to be tested char c1 = 'udc00'; char c2 = 'udbff'; char c3 = 'ud900'; // check the characters if both the characters // are surrogate pair boolean result1 = Character.isSurrogatePair(c2, c1); boolean result2 = Character.isSurrogatePair(c2,c3); // print the result System.out.println("is c2 and c1 a surrogate code pair?"+result1); System.out.println("is c2 and c3 a surrogate code pair?"+result2); } }
Sample Output
Below is the sample output when you run the above example.