Figure 2.1 gives an overview of the primitive data types in Java.
Primitive data types in Java can be divided into three main categories:
Integral types? represent signed integers (byte, short, int, long) and unsigned character values (char)
Floating-point types (float, double)? represent fractional signed numbers
Boolean type (boolean)? represent logical values
Primitive data values are not objects. Each primitive data type defines the range of values in the data type, and operations on these values are defined by special operators in the language (see Chapter 3).
Each primitive data type also has a corresponding wrapper class that can be used to represent a primitive value as an object. Wrapper classes are discussed in Section 10.3.
Minimum value MIN_VALUE
Maximum value MAX_VALUE
Integer data types are byte, short, int, and long (see Table 2.9). Their values are signed integers represented by 2's complement (see Section G.4, p. 598).
Minimum Unicode value
Maximum Unicode value
Characters are represented by the data type char (see Table 2.10). Their values are unsigned integers that denote all the 65536 (216) characters in the 16-bit Unicode character set. This set includes letters, digits, and special characters.
The first 128 characters of the Unicode set are the same as the 128 characters of the 7-bit ASCII character set, and the first 256 characters of the Unicode set correspond to the 256 characters of the 8-bit ISO Latin-1 character set.
Minimum Positive Value MIN_VALUE
Maximum Positive Value MAX_VALUE
Floating-point numbers are represented by the float and double data types.
Floating-point numbers conform to the IEEE 754-1985 binary floating-point standard. Table 2.11 shows the range of values for positive floating-point numbers, but these apply equally to negative floating-point numbers with the '-' sign as prefix. Zero can be either 0.0 or -0.0.
Since the size for representation is finite, certain floating-point numbers can only be represented as approximations. For example, the value of the expression (1.0/3.0) is represented as an approximation due to the finite number of bits used.
True Value Literal
False Value Literal
The data type boolean represents the two logical values denoted by the literals true and false (see Table 2.12).
Boolean values are produced by all relational (see Section 3.9), conditional (see Section 3.12) and boolean logical operators (see Section 3.11), and are primarily used to govern the flow of control during program execution.
Table 2.13 summarizes the pertinent facts about the primitive data types: their width or size, which indicates the number of the bits required to store a primitive value; their range (of legal values), which is specified by the minimum and the maximum values permissible; and the name of the corresponding wrapper class.
Minimum Value, Maximum Value
true, false (no ordering implied)