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
I'm unsure of the formal definition of an integral type, but in short, yes, char
is an integral type in Java, since it can be seen as representing an integer.
You can for instance do
char c1 = 'a' + 'b';
char c2 = 5;
char c3 = c2 + 3;
int i = c3;
char c4 = (char) i;
and so on.
The C specification calls for the char type to be implemented as a 1-byte integer. The specifications for other types are not always so clear. For example, the original Kernigan and Ritchie C book said that, as far as short and long were concerned, among different implementations, you could only rely on the fact that short was no longer than long.