Compared with what we saw of the floating-point types in Chapter 1, the integer types must seem pretty tame and safe! We'll see how valid that assumption is in this chapter.

Java has five integer types named by the keywords `byte, short, char, int,`

and `long.`

The values of these types represent the whole numbers of pure mathematics, which we use for counting and for doing arithmetic that doesn't involve fractions. We must use the word *represent* because Java's integers, unlike the whole numbers, are not infinite.

Table 2-1 shows the bit size, the minimum value, and the maximum value of each of Java's integer types.

Except for type `char,`

which does not have negative values, the ...

Start Free Trial

No credit card required