java.lang.Character toCodePoint(char high, char low)
Description
The toCodePoint(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.toCodePoint(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 toCodePoint() method non statically.
Method Syntax
public static int toCodePoint(char high, char low)
Method Argument
Data Type | Parameter | Description |
---|---|---|
char | high | the high-surrogate code unit |
char | low | the low-surrogate code unit |
Method Returns
The toCodePoint(char high, char low) method of Character class returns the supplementary code point composed from the specified surrogate pair.
Compatibility
Requires Java 1.5 and up
Java Character toCodePoint(char high, char low) Example
Below is a simple java example on the usage of toCodePoint(char high, char low) method of Character class.
package com.javatutorialhq.java.examples; /* * This example source code demonstrates the use of * toCodePoint(char high, char low) * method of Character class. */ public class CharacterToCodePointExample { public static void main(String[] args) { // instantiate two char object char high = 'ud800'; //high surrogate code unit char low = 'udd10'; // low surrogate code unit // Converts the specified surrogate pair // to its supplementary code point value int result = Character.toCodePoint(high, low); // print the result System.out.println(result); } }
Sample Output
Below is the sample output when you run the above example.