Online Java Compiler By
JavaTpoint.com
public class JavaCharcatertoCharsExample1 { public static void main(String[] args) { // Create a char array ch. char ch[]; // Create an integer primitive cp and assign the value. int cp = 0x006e; // Assign the result of integer primitive cp to ch. ch = Character.toChars(cp); String str = "The char array with the UTF-16 representation is given as: "; System.out.print( str ); // Consider a for loop to print the value for ch. for (int i = 0; i < ch.length; i++) { System.out.print( ch[i] ); } } }
Output