7. NumbersWorking with numbers in Java is a subject that every programmer should become proficient in, as nearly every program deals with numbers of one form or another. In this chapter, we primarily use the basic numeric Java types, their object wrappers, and the java.lang.Math class. Table 7.1 summarizes the built-in types that Java offers and lists their wrapper objects available. Note that the boolean type does not have a bit size because it can contain only two discrete values, a value of true or false.
The object wrapper classes are useful when you want to treat a basic type like an object. For example, this might be useful if you want to define an API in terms of objects only. When wrapped as objects, the basic types can also be serialized. |