Java Char Data Type Example

Java program to demonstrate char data type.
public class CharDemo {
  public static void main(String args[]) {
    char ch1, ch2;

    ch1 = 88;  // code for X
    ch2 = 'Y';
    
    System.out.print("ch1 and ch2: ");
    System.out.println(ch1 + " " + ch2);
  }
}
Output:
ch1 and ch2: X Y

Comments