Just now I read \"char is the only unsigned integral primitive type in Java.\" Does this mean the char is one of the integral types in Java?
Same as in C, recently I
Char is an "Integer Data Type" in C and its related progeny. As per the K&R Book, "By definition, chars are just small integers". They are used for storing 'Character' data.
The ASCII Table lists 128 characters, and each text character corresponds to an integer value.
Char Data Type is a 1 Byte (8 Bits). Therefore, they can store upto 2^8 = 256 different integers. (These 256 different integers correspond to different ASCII or UTF characters.)
For example:
As per ASCII standard, the letter "x" is stored as 01111000 (decimal 120).
for e.g., you can Add a value in a char variable, just like any integer!
int main()
{
char a='x';
int b=3+a;
printf("value is:\n%d",b);
return 0;
}
output: b=123 (3 + 120 for the char 'x')
i.e. chars are just numbers (integers: 0-256 (unsigned)).