The char data type is used to store a single character. The character must be surrounded by single quotes, like 'A' or 'c':

Example

char myGrade = 'B';
System.out.println(myGrade);

Alternatively, you can use ASCII values to display certain characters:

Example

char a = 65, b = 66, c = 67;
System.out.println(a);
System.out.println(b);
System.out.println(c);



Practice Excercise Practice now