Fundamental types include the Java primitive types and their corresponding wrapper classes/reference types. Java 5.0 and beyond provide for automatic conversion between these primitive and reference types through autoboxing and unboxing. Numeric promotion is applied to primitive types where appropriate.
There are eight primitive types in Java; each is a reserved keyword. They describe variables that contain single values of the appropriate format and size; see Table 3-1. Primitive types are always the specified precision, regardless of the underlying hardware precisions (e.g., 32- or 64-bit).
\u0000 to \uFFFF
–128 to 127
–32768 to 32767
–2147483648 to 2147483647
–263 to 263 –1
1.4e–45 to 3.4e+38
5e–324 to 1.8e+308
byte, short, int, long,
double are all signed. Type
char is unsigned.
All primitive types, except
boolean, can accept character, decimal,
hexadecimal, octal, and Unicode literal formats, as well as character
escape sequences. Where appropriate, the literal value is automatically
cast or converted. Remember that bits are lost during truncation. The
following is a list of primitive assignment examples:
boolean isTitleFight = true; ...