Java Data Type Tutorial - Java Character.toChars(int codePoint, char[] dst, int dstIndex)








Syntax

Character.toChars(int codePoint, char[] dst, int dstIndex) has the following syntax.

public static int toChars(int codePoint,  char[] dst,  int dstIndex)

Example

In the following code shows how to use Character.toChars(int codePoint, char[] dst, int dstIndex) method.

public class Main {
// w ww  .  j  av a  2 s. com
   public static void main(String[] args) {
      int cp = 0x0036;
      char dst[] = Character.toChars(cp);

      int res = Character.toChars(cp, dst, 0);

      if ( res == 1 ){
         System.out.println( "It is a BMP code point" );
      }
      else if ( res == 2 ){
         System.out.println( "It is a is a supplementary code point" );
      }
   }
}

The code above generates the following result.