Java Character.toChars(int codePoint)

Syntax

Character.toChars(int codePoint) has the following syntax.

public static char[] toChars(int codePoint)

Example

In the following code shows how to use Character.toChars(int codePoint) method.


/* ww w.j  a v  a2 s  .  c  om*/
public class Main {

   public static void main(String[] args) {
      int cp = 0x006f;

      char[] ch = Character.toChars(cp);

      System.out.print( "Char array having cp's UTF-16 representation is " );

      for (int i=0; i<ch.length; i++){
         System.out.print( ch[i] );
      }
   }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable