Primitive Character [char]
ASCII: A character set used by many programming languages that contains all the characters normally used on an English-language keyboard, plus a few special characters. Each character is represented by a particular number.

Unicode
: A character set used by the Java language that includes all the ASCII characters plus many of the characters used in languages with a different alphabet from English.

The char type represents a single 16-bit Unicode character. Java stores characters as unsigned integers with values ranging from 0 to 65535.

A character constant is enclosed in single quotes.

Examples:
       ‘A’ ‘&’ ‘+’ ‘=’ ‘k’
Normally, when we work with characters, we use primitive data types
char.

char ch = 'a';

// Unicode for uppercase Greek omega character

char uniChar = '\u039A';

// an array of chars  

char[] charArray ={ 'a', 'b', 'c', 'd', 'e' };

Even
though chars are not integers, in many cases you can operate on them as if they were integers. This allows you to add two characters together, or to increment the value of a character variable, provided the result is in the allowed range for char data type i.e. 0 to 65535. For example, consider the following program fragment:

char
ch1, ch2, ch3;
ch1
= 88;  // Unicode for X
ch3
= 'Y';
ch2
= ch3++;
System.out.println("ch1 = " + ch1);
System.out.println("ch2 = " + ch2);
System.out.println("ch3 = " + ch3);

This program fragment displays the following output:

 ch1
= X
 ch2
= Y
 ch3
= Z

Comparison of characters

Since characters have numeric Unicode codes ranging from 0 to 65535, they may be compared using the arithmetic comparison operators == (equal), != (not equal), >, >=, <, and <=. The result of such a comparison is the boolean value true or false.

Note:
‘ ’
<0<1< . . . <9< ‘A’ < ‘B’ < . . . < ‘Z’ < ‘a’ < ‘b’ < . . . < ‘z’

Example: The code:
 
boolean flag1, flag2;
 
char ch1 = ‘R’;
 
char ch2 = ch1;
 flag1
= ‘b’ < ‘B’; flag2 = ‘M’ < ‘a’;

System.out.println(“flag1 =+ flag1 + “, flag2 =+ flag2);
System.out.println(ch1 == ch2);
Outputs:
 flag1
= false, flag2 = true
 
true