Online Java Compiler By
JavaTpoint.com
public class JavaCharactervalueOfExample1 { public static void main(String[] args) { // Create two character primitives c1 and c2. Character c1, c2; // Create two char primitives and assign the values. char ch1 = 'A'; char ch2 = 'h'; // Assign the character values of ch1 and ch2 to c1 and c2. c1 = Character.valueOf(ch1); c2 = Character.valueOf(ch2); String str1 = "The character value of the character '" + ch1 + "' is given as: " + c1; String str2 = "The character value of the character '" + ch2 + "' is given as: " + c2; // Print the values of ch1 and ch2. System.out.println( str1 ); System.out.println( str2 ); } }
Output