Java Reference
In-Depth Information
133
Chapter 4 Fundamental Data Types
C HAPTER G OALS
ȗ To understand integer and floating-point numbers
ȗ To recognize the limitations of the numeric types
ȗ To become aware of causes for overflow and roundoff errors
ȗ To understand the proper use of constants
ȗ To write arithmetic expressions in Java
ȗ To use the String type to define and manipulate character strings
ȗ To learn how to read program input and produce formatted output
This chapter teaches how to manipulate numbers and character strings in Java. The
goal of this chapter is to gain a firm understanding of the fundamental Java data
types.
You will learn about the properties and limitations of the number types in Java. You
will see how to manipulate numbers and strings in your programs. Finally, we cover
the important topic of input and output, which enables you to implement interactive
programs.
133
134
4.1 Number Types
In Java, every value is either a reference to an object, or it belongs to one of the eight
primitive types shown in Table 1 .
Java has eight primitive types, including four integer types and two floating-point
types.
Six of the primitive types are number types, four of them for integers and two for
floating-point numbers.
Search WWH ::




Custom Search